Skip to content

Commit

Permalink
Merge pull request #90 from nirvdrum/short_circuit_string_tokenization
Browse files Browse the repository at this point in the history
Updated the RegExp to catch Strings earlier in the tokenization process.
  • Loading branch information
tenderlove committed Oct 2, 2012
2 parents 465ae0a + 97bdb23 commit 4be2aef
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_~]/
# Check for a String type, being careful not to get caught by hash keys, hex values, and
# special floats (e.g., -.inf).
when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/
if string.length > 5
@string_cache[string] = true
return string
Expand Down

0 comments on commit 4be2aef

Please sign in to comment.