Class: TZInfo::UnaryMinusGlobalStringDeduper Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/tzinfo/string_deduper.rb |
Overview
An implementation of StringDeduper
using the String#-@
method where
that method performs deduplication (Ruby 2.5 and later).
Note that this is slightly different to the plain StringDeduper
implementation. In this implementation, frozen literal strings are already
in the pool and are candidates for being returned, even when passed
another equal frozen non-literal string. StringDeduper
will always
return frozen strings.
There are also differences in encoding handling. This implementation will
treat strings with different encodings as different strings.
StringDeduper
will treat strings with the compatible encodings as the
same string.
Instance Method Summary
- #dedupe(string) ⇒ bool Internal use only
Instance Method Details
#dedupe(string) ⇒ bool
# File 'lib/tzinfo/string_deduper.rb', line 94
def dedupe(string) # String#-@ on Ruby 2.6 will dedupe a frozen non-literal String. Ruby # 2.5 will just return frozen strings. # # The pooled implementation can't tell the difference between frozen # literals and frozen non-literals, so must always return frozen String # instances to avoid doing unncessary work when loading format 2 # TZInfo::Data modules. # # For compatibility with the pooled implementation, just return frozen # string instances (acting like Ruby 2.5). return string if string.frozen? -string end