Merge pull request #2716 from github/faster-string-tokenizer

Use negative lookbehind when tokenizing string literals
This commit is contained in:
Arfon Smith
2015-11-05 08:40:34 -08:00

View File

@@ -86,13 +86,13 @@ module Linguist
if s.peek(1) == "\"" if s.peek(1) == "\""
s.getch s.getch
else else
s.skip_until(/[^\\]"/) s.skip_until(/(?<!\\)"/)
end end
elsif s.scan(/'/) elsif s.scan(/'/)
if s.peek(1) == "'" if s.peek(1) == "'"
s.getch s.getch
else else
s.skip_until(/[^\\]'/) s.skip_until(/(?<!\\)'/)
end end
# Skip number literals # Skip number literals