Module: Datadog::Core::Utils::SafeDup
- Defined in:
- lib/datadog/core/utils/safe_dup.rb
Overview
Helper methods for safer dup
Defined Under Namespace
Modules: RefineNil
Class Method Summary collapse
Class Method Details
.frozen_dup(v) ⇒ Object
28 29 30 |
# File 'lib/datadog/core/utils/safe_dup.rb', line 28 def self.frozen_dup(v) -v if v end |
.frozen_or_dup(v) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/datadog/core/utils/safe_dup.rb', line 21 def self.frozen_or_dup(v) # If the string is not frozen, the +(-v) will: # - first create a frozen deduplicated copy with -v # - then it will dup it more efficiently with +v v.frozen? ? v : +(-v) end |