Skip to content

Instantly share code, notes, and snippets.

@hinrik
Created November 6, 2017 21:21
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 hinrik/4dedeb082b1e57973578ce91720b68f8 to your computer and use it in GitHub Desktop.
Save hinrik/4dedeb082b1e57973578ce91720b68f8 to your computer and use it in GitHub Desktop.
require "string_pool"
pool = StringPool.new
pool.get("foo")
(0..500).each do |i|
# add random stuff to grow the pool
random_str = (1..8).map{ ((rand(2)==1?65:97) + rand(25)).chr }.join
pool.get(random_str)
# id for "foo" is not always the same, lost when resizing/rehashing?
puts "%3d %d" % {pool.size, pool.get("foo").object_id}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment