Commit a45df748 authored by 's avatar

Added a couple of minor performance tweaks after profiling.

parent 3132af40
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""HTML formated DocumentTemplates """HTML formated DocumentTemplates
$Id: DT_HTML.py,v 1.15 1999/03/10 00:15:07 klm Exp $""" $Id: DT_HTML.py,v 1.16 1999/03/18 15:07:03 brian Exp $"""
from DT_String import String, FileMixin from DT_String import String, FileMixin
import DT_String, regex import DT_String, regex
...@@ -97,6 +97,8 @@ class dtml_re_class: ...@@ -97,6 +97,8 @@ class dtml_re_class:
name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match,
end_match=regex.compile('[\0- ]*\(/\|end\)', end_match=regex.compile('[\0- ]*\(/\|end\)',
regex.casefold).match, regex.casefold).match,
find=find,
strip=strip
): ):
s=find(text,'<!--#',start) s=find(text,'<!--#',start)
if s < 0: return s if s < 0: return s
...@@ -128,13 +130,12 @@ class dtml_re_class: ...@@ -128,13 +130,12 @@ class dtml_re_class:
return s return s
def group(self,*args): def group(self, *args):
g=self.__dict__ get=self.__dict__.get
if len(args)==1: return g[args[0]] if len(args)==1:
r=[] return get(args[0])
for arg in args: return tuple(map(get, args))
r.append(g[arg])
return tuple(r)
class HTML(DT_String.String): class HTML(DT_String.String):
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
# attributions are listed in the accompanying credits file. # attributions are listed in the accompanying credits file.
# #
############################################################################## ##############################################################################
"$Id: gparse.py,v 1.9 1999/03/10 00:15:08 klm Exp $" "$Id: gparse.py,v 1.10 1999/03/18 15:07:03 brian Exp $"
import sys, parser, symbol, token import sys, parser, symbol, token
from symbol import test, suite, argument, arith_expr, shift_expr from symbol import test, suite, argument, arith_expr, shift_expr
...@@ -97,10 +97,11 @@ from parser import sequence2ast, compileast, ast2list ...@@ -97,10 +97,11 @@ from parser import sequence2ast, compileast, ast2list
ParseError='Expression Parse Error' ParseError='Expression Parse Error'
def munge(ast): def munge(ast, STAR=STAR, DOT=DOT, LSQB=LSQB, COLON=COLON, trailer=trailer):
if ISTERMINAL(ast[0]): return ast0=ast[0]
if ISTERMINAL(ast0): return
else: else:
if ast[0]==term and len(ast) > 2: if ast0==term and len(ast) > 2:
keep_going=1 keep_going=1
while keep_going: while keep_going:
keep_going=0 keep_going=0
...@@ -113,7 +114,7 @@ def munge(ast): ...@@ -113,7 +114,7 @@ def munge(ast):
for a in ast[1:]: munge(a) for a in ast[1:]: munge(a)
elif ast[0]==power: elif ast0==power:
keep_going=1 keep_going=1
while keep_going: while keep_going:
keep_going=0 keep_going=0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment