Author: aaugustin Date: 2011-10-04 13:11:41 -0700 (Tue, 04 Oct 2011) New Revision: 16924
Modified: django/trunk/AUTHORS django/trunk/django/utils/jslex.py Log: Fixed #16971 - Made the parsing of javascript files by 'makemessages' much faster. Thanks Antti Haapala for the implementation and Ned Batchelder for the patch. Modified: django/trunk/AUTHORS =================================================================== --- django/trunk/AUTHORS 2011-10-04 05:57:51 UTC (rev 16923) +++ django/trunk/AUTHORS 2011-10-04 20:11:41 UTC (rev 16924) @@ -222,6 +222,7 @@ Janos Guljas Thomas Güttler <h...@tbz-pariv.de> Horst Gutmann <ze...@zerokspot.com> + Antti Haapala <an...@industrialwebandmagic.com> Scot Hacker <shac...@birdhouse.org> dAniel hAhler hambaloney Modified: django/trunk/django/utils/jslex.py =================================================================== --- django/trunk/django/utils/jslex.py 2011-10-04 05:57:51 UTC (rev 16923) +++ django/trunk/django/utils/jslex.py 2011-10-04 20:11:41 UTC (rev 16924) @@ -51,21 +51,27 @@ Yields pairs (`name`, `tokentext`). """ - while text: - eaten = 0 - for match in self.regexes[self.state].finditer(text): - for name, toktext in match.groupdict().iteritems(): - if toktext is not None: - tok = self.toks[name] - new_state = tok.next - eaten += len(toktext) - yield (tok.name, toktext) - if new_state: - self.state = new_state + end = len(text) + state = self.state + regexes = self.regexes + toks = self.toks + start = 0 + + while start < end: + for match in regexes[state].finditer(text, start): + name = match.lastgroup + tok = toks[name] + toktext = match.group(name) + start += len(toktext) + yield (tok.name, toktext) + + if tok.next: + state = tok.next break - text = text[eaten:] + self.state = state + class JsLexer(Lexer): """ A Javascript lexer -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.