aberrant80
aberrant80

Reputation: 12997

Is there any performance reasons to change a function into a static function?

When developing actionscript/flex in IntelliJ IDEA, there's this IDEA inspection that suggests that so-and-so private function can be turned into a static function.

I've been ignoring it for a while now, but I'm curious as to whether, in actionscript, there's any performance benefit of declaring functions that can be static as static.

Coming from a Java background, it seems odd to me for IDEA to be suggesting that a function be made static just because it can... yet such an inspection does not exist in the Java editor.

For example, IDEA would suggest that I make the following static:

    private function eventName(attributeName:String):String {
        return attributeName + EVENT_NAME_SUFFIX;
    }

Upvotes: 2

Views: 44

Answers (1)

Panzercrisis
Panzercrisis

Reputation: 4750

No. There is actually quite an incentive to do the opposite.

This should not be so - naturally, one would think static functions would be faster - but ActionScript 3 does not behave this way. Whoever wrote IDEA did not do their research on this, but rather they went with their instincts and with what should be true.

Here's one source of information on this subject:

http://blog.controul.com/2009/04/how-slow-is-static-access-in-as3avm2-exactly/

Upvotes: 1

Related Questions