Skip to content

Instantly share code, notes, and snippets.

@pbm
Created February 1, 2011 23:06
Show Gist options
  • Save pbm/806923 to your computer and use it in GitHub Desktop.
Save pbm/806923 to your computer and use it in GitHub Desktop.
class IdentitySet
primitive_nobridge '__removeAll', 'removeAll:'
def clear
__removeAll(self) # This idiom optimized in C code.
end
end
idset = IdentitySet.new
1_000_000.times { |i| idset << i }
p idset.size
idset.clear
p idset.size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment