mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Use negative lookbehind when tokenizing string literals
This can double the speed of tokenizing large RTF files that use \'hh escape sequences.
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user