Skip to content

Commit

Permalink
Freeze default options to avoid useless new hash allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
ismasan committed Sep 1, 2020
1 parent 3ead0ea commit 5393636
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/hash_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def inject_with_index(injected)
end

module HashMapper
DEFAULT_OPTIONS = {}.freeze

def self.extended(base)
base.class_eval do
Expand Down Expand Up @@ -73,11 +74,11 @@ def using(mapper_class)
{ using: mapper_class }
end

def normalize(a_hash, options: {})
def normalize(a_hash, options: DEFAULT_OPTIONS)
perform_hash_mapping a_hash, :normalize, options
end

def denormalize(a_hash, options: {})
def denormalize(a_hash, options: DEFAULT_OPTIONS)
perform_hash_mapping a_hash, :denormalize, options
end

Expand Down

0 comments on commit 5393636

Please sign in to comment.