summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org>2014-09-01 20:09:10 -0400
committerDaniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org>2014-09-01 20:09:10 -0400
commitcdf6c832c067112ef95fbe0dd0c5b65cf9101eae (patch)
treebfab78d110362c7df89b822d1ac2d77dbeaa4d7b
parent459599ecd7c9517f3480a96b151026fb69d8624b (diff)
parent705a7eb707f9d4ac5ccd1474f9bb61730f9f12e7 (diff)
downloadhashie-3-3-stable.tar.gz
Merge pull request #221 from kubum/object-alloc3-3-stable
Object allocation during parsing method name
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/hashie/mash.rb4
2 files changed, 3 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3266618..108ed5d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
## Next Release
* Your contribution here.
+* [#221](https://github.com/intridea/hashie/pull/221): Reduce amount of allocated objects on calls with suffixes in Hashie::Mash - [@kubum](https://github.com/kubum).
## 3.3.1 (8/26/2014)
diff --git a/lib/hashie/mash.rb b/lib/hashie/mash.rb
index 182fddb..b7ad40b 100644
--- a/lib/hashie/mash.rb
+++ b/lib/hashie/mash.rb
@@ -58,6 +58,7 @@ module Hashie
include Hashie::Extensions::PrettyInspect
ALLOWED_SUFFIXES = %w(? ! = _)
+ SUFFIXES_PARSER = /(.*?)([#{ALLOWED_SUFFIXES.join}]?)$/
def self.load(path, options = {})
@_mashes ||= new do |h, file_path|
@@ -251,8 +252,7 @@ module Hashie
protected
def method_suffix(method_name)
- suffixes_regex = ALLOWED_SUFFIXES.join
- match = method_name.to_s.match(/(.*?)([#{suffixes_regex}]?)$/)
+ match = method_name.to_s.match(SUFFIXES_PARSER)
[match[1], match[2]]
end