Skip to content

Instantly share code, notes, and snippets.

@ailabs-software
Created September 1, 2014 21:26
Show Gist options
  • Save ailabs-software/a96a7272acf46c20e77f to your computer and use it in GitHub Desktop.
Save ailabs-software/a96a7272acf46c20e77f to your computer and use it in GitHub Desktop.
Removes 136,000 positions from an array of 278,000 in 50ms.
function filterOutPositions(array, positions) // utility code, @param -- positions to remove
{
var BE_DELETED = {};
var arr = array.slice(0); // Clone the array so it can be re-used (non-destructive)
var pos_len = positions.length;
for (var i=0; i < pos_len; i++)
{
arr[ positions[i] ] = BE_DELETED;
}
return arr.filter(function(arr_item) { return arr_item !== BE_DELETED; });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment