1
0
Fork 0

Moved closure out of getMemberVisibility

This was defining a function on every call for no particular reason other
than being lazy, it seems.

Performance poopoo.
perfodd
Mike Gerwitz 2014-02-03 23:55:41 -05:00
parent 66cab74cc1
commit 5047d895c0
1 changed files with 15 additions and 11 deletions

View File

@ -297,35 +297,39 @@ exports.buildGetterSetter = function(
*/ */
function getMemberVisibility( members, keywords, name ) function getMemberVisibility( members, keywords, name )
{ {
var viserr = function()
{
throw TypeError(
"Only one access modifier may be used for definition of '" +
name + "'"
);
}
// there's cleaner ways of doing this, but consider it loop unrolling for // there's cleaner ways of doing this, but consider it loop unrolling for
// performance // performance
if ( keywords[ 'private' ] ) if ( keywords[ 'private' ] )
{ {
( keywords[ 'public' ] || keywords[ 'protected' ] ) && viserr(); ( keywords[ 'public' ] || keywords[ 'protected' ] )
&& viserr( name );
return members[ 'private' ]; return members[ 'private' ];
} }
else if ( keywords[ 'protected' ] ) else if ( keywords[ 'protected' ] )
{ {
( keywords[ 'public' ] || keywords[ 'private' ] ) && viserr(); ( keywords[ 'public' ] || keywords[ 'private' ] )
&& viserr( name );
return members[ 'protected' ]; return members[ 'protected' ];
} }
else else
{ {
// public keyword is the default, so explicitly specifying it is only // public keyword is the default, so explicitly specifying it is only
// for clarity // for clarity
( keywords[ 'private' ] || keywords[ 'protected' ] ) && viserr(); ( keywords[ 'private' ] || keywords[ 'protected' ] )
&& viserr( name );
return members[ 'public' ]; return members[ 'public' ];
} }
} }
function viserr( name )
{
throw TypeError(
"Only one access modifier may be used for definition of '" +
name + "'"
);
}
/** /**
* Scan each level of visibility for the requested member * Scan each level of visibility for the requested member