1
0
Fork 0

Refactored abstract method regeneration logic into a array_shrink() function

closure/master
Mike Gerwitz 2010-11-14 21:39:46 -05:00
parent d4593725a4
commit 1a9cc40c31
1 changed files with 29 additions and 12 deletions

View File

@ -207,22 +207,39 @@ function prop_copy( props, dest, result_data )
// because the length of the array remains the same after deleting elements)
if ( abstract_regen )
{
// copy the methods into a new array by pushing them onto it, to ensure
// the length property of the array will work properly
var methods_new = [];
for ( var i = 0, len = abstract_methods.length; i < len; i++ )
{
var method = abstract_methods[ i ];
if ( method === undefined )
{
continue;
}
result_data.abstractMethods = array_shrink( abstract_methods );
}
}
methods_new.push( method );
/**
* Shrinks an array, removing undefined elements
*
* Pushes all items onto a new array, removing undefined elements. This ensures
* that the length of the array represents correctly the number of elements in
* the array.
*
* @param {Array} items array to shrink
*
* @return {Array} shrunken array
*/
function array_shrink( items )
{
// copy the methods into a new array by pushing them onto it, to ensure
// the length property of the array will work properly
var arr_new = [];
for ( var i = 0, len = items.length; i < len; i++ )
{
var item = items[ i ];
if ( item === undefined )
{
continue;
}
result_data.abstractMethods = methods_new;
arr_new.push( item );
}
return arr_new;
}