Commit a45df748 authored by 's avatar

Added a couple of minor performance tweaks after profiling.

parent 3132af40
......@@ -84,7 +84,7 @@
##############################################################################
"""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
import DT_String, regex
......@@ -97,6 +97,8 @@ class dtml_re_class:
name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match,
end_match=regex.compile('[\0- ]*\(/\|end\)',
regex.casefold).match,
find=find,
strip=strip
):
s=find(text,'<!--#',start)
if s < 0: return s
......@@ -128,13 +130,12 @@ class dtml_re_class:
return s
def group(self,*args):
g=self.__dict__
if len(args)==1: return g[args[0]]
r=[]
for arg in args:
r.append(g[arg])
return tuple(r)
def group(self, *args):
get=self.__dict__.get
if len(args)==1:
return get(args[0])
return tuple(map(get, args))
class HTML(DT_String.String):
......
......@@ -82,7 +82,7 @@
# 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
from symbol import test, suite, argument, arith_expr, shift_expr
......@@ -97,10 +97,11 @@ from parser import sequence2ast, compileast, ast2list
ParseError='Expression Parse Error'
def munge(ast):
if ISTERMINAL(ast[0]): return
def munge(ast, STAR=STAR, DOT=DOT, LSQB=LSQB, COLON=COLON, trailer=trailer):
ast0=ast[0]
if ISTERMINAL(ast0): return
else:
if ast[0]==term and len(ast) > 2:
if ast0==term and len(ast) > 2:
keep_going=1
while keep_going:
keep_going=0
......@@ -113,7 +114,7 @@ def munge(ast):
for a in ast[1:]: munge(a)
elif ast[0]==power:
elif ast0==power:
keep_going=1
while keep_going:
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