class TZInfo::UnaryMinusGlobalStringDeduper

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/tzinfo/string_deduper.rbs

class TZInfo::UnaryMinusGlobalStringDeduper
  def dedupe: (String string) -> untyped
end

:nodoc:
@private
same string.
{StringDeduper} will treat strings with the compatible encodings as the
treat strings with different encodings as different strings.
There are also differences in encoding handling. This implementation will
return frozen strings.
another equal frozen non-literal string. {StringDeduper} will always
in the pool and are candidates for being returned, even when passed
implementation. In this implementation, frozen literal strings are already
Note that this is slightly different to the plain {StringDeduper}
that method performs deduplication (Ruby 2.5 and later).
An implementation of {StringDeduper} using the ‘String#-@` method where

def dedupe(string)

Experimental RBS support (using type sampling data from the type_fusion project).

def dedupe: (String string) -> untyped

This signature was generated using 7 samples from 1 application.

Returns:
  • (bool) - `string` if it is frozen, otherwise a frozen, possibly

Parameters:
  • string (String) -- the string to deduplicate.

Other tags:
    Private: -
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