var a = []; /// is better than
var a = new Array();
The same applies for creating Objects.
var copy : Array = sourceArray.concat();
StringUtils.trim( “text with space at end ” );
Class definition:
package {
public final class StringUtils
{
public static function trim( s : String ) : String
{
var trimmed : String;
// implementation
return trimmed;
}}}
public const APPLICATION_PUBLISHER : String = “Company, Inc.”;
public final class StringUtils
someVeryLongMethodNameDoesntReallyImpactPerformanceMuch();
var i=0; j=10; k=200; // ... is no faser than if on separate lines
if ( condition ){
// handle condition
//--------------------------------------- IDENTICAL MEMORY USAGE:
switch ( condition )
{
case “A”:
// logic to handle case A
break;
case “B”:
// logic to handle case B
break;
}
if ( conditionThatHappensAlot ) {
// logic to handle frequently met condition
} else if ( conditionThatHappensSomtimes ) {
// handle the case that happens occasionally
} else {
// handle the case that doesn’t happen that often
}
(var i: int = 0; i < n; i++) // is better than...
(var i: Number = 0; i < n; i++)
var toRadians:Number = a*180/Math.PI;
for (..){ b* toRadians; }
createChildren();
commitProperties();
updateDisplayList();
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)