Fixed #16971 - Made the parsing of javascript files by 'makemessages' much faster. Thanks Antti Haapala for the implementation and Ned Batchelder for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16924 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f3304d3310
commit
2a044732f6
1
AUTHORS
1
AUTHORS
|
@ -222,6 +222,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
Janos Guljas
|
Janos Guljas
|
||||||
Thomas Güttler <hv@tbz-pariv.de>
|
Thomas Güttler <hv@tbz-pariv.de>
|
||||||
Horst Gutmann <zerok@zerokspot.com>
|
Horst Gutmann <zerok@zerokspot.com>
|
||||||
|
Antti Haapala <antti@industrialwebandmagic.com>
|
||||||
Scot Hacker <shacker@birdhouse.org>
|
Scot Hacker <shacker@birdhouse.org>
|
||||||
dAniel hAhler
|
dAniel hAhler
|
||||||
hambaloney
|
hambaloney
|
||||||
|
|
|
@ -51,19 +51,25 @@ class Lexer(object):
|
||||||
|
|
||||||
Yields pairs (`name`, `tokentext`).
|
Yields pairs (`name`, `tokentext`).
|
||||||
"""
|
"""
|
||||||
while text:
|
end = len(text)
|
||||||
eaten = 0
|
state = self.state
|
||||||
for match in self.regexes[self.state].finditer(text):
|
regexes = self.regexes
|
||||||
for name, toktext in match.groupdict().iteritems():
|
toks = self.toks
|
||||||
if toktext is not None:
|
start = 0
|
||||||
tok = self.toks[name]
|
|
||||||
new_state = tok.next
|
while start < end:
|
||||||
eaten += len(toktext)
|
for match in regexes[state].finditer(text, start):
|
||||||
yield (tok.name, toktext)
|
name = match.lastgroup
|
||||||
if new_state:
|
tok = toks[name]
|
||||||
self.state = new_state
|
toktext = match.group(name)
|
||||||
|
start += len(toktext)
|
||||||
|
yield (tok.name, toktext)
|
||||||
|
|
||||||
|
if tok.next:
|
||||||
|
state = tok.next
|
||||||
break
|
break
|
||||||
text = text[eaten:]
|
|
||||||
|
self.state = state
|
||||||
|
|
||||||
|
|
||||||
class JsLexer(Lexer):
|
class JsLexer(Lexer):
|
||||||
|
|
Loading…
Reference in New Issue