views:

117

answers:

5

We are in process of optimization of Flex AS3 Application.

One of my team member suggested us to make varible name length smaller to optimize the application performence.

i.e.

var IsRegionSelected:Boolean = false; //Slower
var IsRS:Boolean = false; //faster

Is it True? Please provide your views...

A: 

There's a very small performance gain, but if you plan to use this application again later, it's not worth your sanity. Do absolutely any other optimization you can before this one - and if it's really slow enough to need optimizing, then there are definitely other factors that you'll need to take care of first before variable names.

Cut anything else you can before resorting to 1-2 millisecond boosts.

Matchu
I'd be impressed if it's that.
DeadMG
A: 

yep.. i second it. changing the name length is not gonna help you. concentrate on item renderers, effects, states and transitions. those may be killing your resource. also checkout for any embedding images, embedding fonts, etc, since those will increase ur final swf file size and increase initial loading time.

cheers, PK

Anoop
A: 

I don't think so, the way you use your variable name does matter than its length.

Good code should be consistent. Whether that means setting rules for the names of variables and functions, adopting standard approaches, or simply making sure all of your code is indented the same way, consistency makes your code easier for others to read.

One should later construe on what is your variable name declared.

var g:String;
var gang:String;

Both perform the same operation, one is more readability where someone going through your code will also construe it.

Vinothbabu
A: 

As Matchu says, there is a difference but a small one.

You should consider assigning meaningful ids to your variables instead of just using simple chars which have no sense.

Adrian Pirvulescu
+8  A: 

No, the gain you will obtain will be only for the size of the swf.

String are put into a constant pool and instruction refering to this String will use an index.

it can be seen as (very schematic) :

constant pool:

[0] IsRegionSelected
[1] IsRS

usage:

value at 0 = false
value at 1 = false

Your code will be probably translated as (for local variable):

push false
setlocal x

push false
setlocal y

where x and y are register int assign by the compiler, so no difference if it's register 2 or register 4

For more detailed read the avm specification

Patrick