summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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