[Zope3-checkins] CVS: Zope3/src/zope/tal - talinterpreter.py:1.13
Fred L. Drake, Jr.
fred@zope.com
Mon, 7 Apr 2003 18:27:18 -0400
Update of /cvs-repository/Zope3/src/zope/tal
In directory cvs.zope.org:/tmp/cvs-serv25443
Modified Files:
talinterpreter.py
Log Message:
Some small speedups, mostly in do_startTag().
=== Zope3/src/zope/tal/talinterpreter.py 1.12 => 1.13 ===
--- Zope3/src/zope/tal/talinterpreter.py:1.12 Mon Apr 7 13:02:22 2003
+++ Zope3/src/zope/tal/talinterpreter.py Mon Apr 7 18:27:17 2003
@@ -40,12 +40,18 @@
"disabled", "readonly", "multiple", "selected", "noresize",
"defer"
]
+d = {}
+for s in BOOLEAN_HTML_ATTRS:
+ d[s] = 1
+BOOLEAN_HTML_ATTRS = d
+
+_nulljoin = ''.join
def normalize(text):
# Now we need to normalize the whitespace in implicit message ids and
# implicit $name substitution values by stripping leading and trailing
# whitespace, and folding all internal whitespace to a single space.
- return ' '.join(text.split())
+ return _nulljoin(text.split())
class AltTALGenerator(TALGenerator):
@@ -245,8 +251,8 @@
# for start tags with no attributes; those are optimized down
# to rawtext events. Hence, there is no special "fast path"
# for that case.
- _stream_write = self._stream_write
- _stream_write("<" + name)
+ L = ["<", name]
+ append = L.append
col = self.col + _len(name) + 1
wrap = self.wrap
align = col + 1
@@ -265,15 +271,17 @@
if (wrap and
col >= align and
col + 1 + slen > wrap):
- _stream_write("\n" + " "*align)
+ append("\n")
+ append(" "*align)
col = align + slen
else:
- s = " " + s
+ append(" ")
col = col + 1 + slen
- _stream_write(s)
- _stream_write(end)
+ append(s)
+ append(end)
col = col + endlen
finally:
+ self._stream_write(_nulljoin(L))
self.col = col
bytecode_handlers["startTag"] = do_startTag
@@ -398,8 +406,9 @@
def do_rawtextBeginScope_tal(self, (s, col, position, closeprev, dict)):
self._stream_write(s)
self.col = col
- self.do_setPosition(position)
engine = self.engine
+ self.position = position
+ engine.setPosition(position)
if closeprev:
engine.endScope()
engine.beginScope()