1
0
Fork 0

Began moving abstract logic out of propCopy

closure/master
Mike Gerwitz 2011-01-24 20:58:58 -05:00
parent 96d2f74dae
commit 5a3b401647
2 changed files with 17 additions and 9 deletions

View File

@ -217,6 +217,15 @@ var extend = ( function( extending )
members = member_builder.initMembers( prototype ), members = member_builder.initMembers( prototype ),
abstract_methods = ( base.abstractMethods || [] ).slice(); abstract_methods = ( base.abstractMethods || [] ).slice();
// it's much faster to lookup a hash than it is to iterate through an
// entire array each time we need to find an existing abstract method
var abstract_map = {};
for ( var i = 0, len = abstract_methods.length; i < len; i++ )
{
var method = abstract_methods[ i ];
abstract_map[ method ] = i;
}
util.propCopy( props, prototype, { util.propCopy( props, prototype, {
each: function( name, value ) each: function( name, value )
{ {
@ -239,12 +248,18 @@ var extend = ( function( extending )
{ {
var pre = prototype[ name ]; var pre = prototype[ name ];
this.performDefault( name, func, is_abstract );
if ( ( pre === undefined ) && is_abstract ) if ( ( pre === undefined ) && is_abstract )
{ {
abstract_methods.push( name ); abstract_methods.push( name );
} }
else if ( pre && ( is_abstract === false ) )
this.performDefault( name, func, is_abstract ); {
// if this was a concrete method, then it should no longer
// be marked as abstract
delete abstract_methods[ abstract_map[ name ] ];
}
}, },
methodOverride: function( name, pre, func ) methodOverride: function( name, pre, func )

View File

@ -449,13 +449,6 @@ exports.overrideMethod = function(
); );
} }
} }
// if this was a concrete method, then it should no longer be marked as
// abstract
if ( is_abstract === false )
{
delete abstract_methods[ abstract_map[ name ] ];
}
} }
// this is the method that will be invoked when the requested // this is the method that will be invoked when the requested