Skip to content

Commit

Permalink
Short-circuit String tokenization.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Oct 2, 2012
1 parent 08da2c2 commit e806575
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/psych/scalar_scanner.rb
Expand Up @@ -24,7 +24,9 @@ def tokenize string
return string if @string_cache.key?(string)

case string
when /^[A-Za-z_~]/
# Make sure it's not a hex string, a special float (e.g., -.inf), or hash key. Look for any character that would
# immediately qualify it as a String type.
when /^[A-Za-z_~]/, /^[^(?:0x)\.:-][A-Za-z\s!@#\$%\^&\*\(\)\{\}\|\/\\]+/
if string.length > 5
@string_cache[string] = true
return string
Expand Down

0 comments on commit e806575

Please sign in to comment.