class TZInfo::StringDeduper
:nodoc:
@private
either a pooled copy of a given ‘String` or add the instance to the pool.
Maintains a pool of `String` instances. The {#dedupe} method will return
def create_hash(&block)
-
(Hash)
- a `Hash` to store pooled `String` instances.
Parameters:
-
block
(Proc
) -- Default value block to be passed to `Hash.new`.
def create_hash(&block) Hash.new(&block) end
def dedupe(string)
-
(bool)
- `string` if it is frozen, otherwise a frozen, possibly
Parameters:
-
string
(String
) -- the string to deduplicate.
def dedupe(string) return string if string.frozen? @strings[string] end
def initialize
def initialize @strings = create_hash do |h, k| v = k.dup.freeze h[v] = v end end