Skip to content

Instantly share code, notes, and snippets.

@andrewbranch
Last active November 18, 2015 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewbranch/699d7ec064b006c8d474 to your computer and use it in GitHub Desktop.
Save andrewbranch/699d7ec064b006c8d474 to your computer and use it in GitHub Desktop.
One of these is around 10x faster than the other two
// filtered is an Immutable.Seq (lazy sequence) with 307 entries
let withinCountry = filtered.filter(p => p.get('locations').some(isSameCountry(yourLocation)));
let outsideCountry1 = filtered.filter(p => !withinCountry.includes(p));
let outsideCountry2 = filtered.filter(p => !p.get('locations').some(isSameCountry(yourLocation)));
let outsideCountry3 = filtered.toSet().subtract(withinCountry);
return withinCountry.sort(someWayOfSorting)
.concat(outsideCountryN.sort(someOtherWayOfSorting))
.take(10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment