1
0
Fork 0
This repository has been archived on 2019-12-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
neinomaten/vendor/htree/htree/fstr.rb

32 lines
635 B
Ruby

require 'htree/modules'
module HTree
# :stopdoc:
def HTree.with_frozen_string_hash
if Thread.current[:htree_frozen_string_hash]
yield
else
begin
Thread.current[:htree_frozen_string_hash] = {}
yield
ensure
Thread.current[:htree_frozen_string_hash] = nil
end
end
end
def HTree.frozen_string(str)
if h = Thread.current[:htree_frozen_string_hash]
if s = h[str]
s
else
str = str.dup.freeze unless str.frozen?
h[str] = str
end
else
str = str.dup.freeze unless str.frozen?
str
end
end
# :startdoc:
end