diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2019-04-26 18:57:03 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-06-25 15:56:20 +0900 |
commit | 5a4d2b9f2f1cb5124a4dccc103c7bbe8d27554d5 (patch) | |
tree | 21d947b0f2ba5947708aaebf0565d945409bef7c | |
parent | 63f78bbaaea4bb0b7009e50a938ef146416c53c2 (diff) | |
download | ruby-5a4d2b9f2f1cb5124a4dccc103c7bbe8d27554d5.tar.gz |
Remove string_cache in ScalarScanner
-rw-r--r-- | ext/psych/lib/psych/scalar_scanner.rb | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb index f89aa68ff8..e92fe27fd7 100644 --- a/ext/psych/lib/psych/scalar_scanner.rb +++ b/ext/psych/lib/psych/scalar_scanner.rb @@ -23,7 +23,6 @@ module Psych # Create a new scanner def initialize class_loader - @string_cache = {} @symbol_cache = {} @class_loader = class_loader end @@ -31,19 +30,14 @@ module Psych # Tokenize +string+ returning the Ruby object def tokenize string return nil if string.empty? - return string if @string_cache.key?(string) return @symbol_cache[string] if @symbol_cache.key?(string) # Check for a String type, being careful not to get caught by hash keys, hex values, and # special floats (e.g., -.inf). if string.match?(/^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/) || string.match?(/\n/) - if string.length > 5 - @string_cache[string] = true - return string - end + return string if string.length > 5 if string.match?(/^[^ytonf~]/i) - @string_cache[string] = true string elsif string == '~' || string.match?(/^null$/i) nil @@ -52,7 +46,6 @@ module Psych elsif string.match?(/^(no|false|off)$/i) false else - @string_cache[string] = true string end elsif string.match?(TIME) @@ -94,7 +87,6 @@ module Psych i elsif string.match?(FLOAT) if string.match?(/\A[-+]?\.\Z/) - @string_cache[string] = true string else Float(string.gsub(/[,_]|\.([Ee]|$)/, '\1')) @@ -103,7 +95,6 @@ module Psych int = parse_int string.gsub(/[,_]/, '') return int if int - @string_cache[string] = true string end end |