Commit 45a73765 authored by Fred Drake's avatar Fred Drake

TALGenerator.optimize():

    Re-write generated instructions:  (op, arg1, arg2, ...) becomes
    (op, (arg1, arg2, ...)) to reflect the change in the dispatch
    mechanism in TALInterpreter -- this avoids a tuple concatenation
    at dispatch time.
parent 9e161e97
...@@ -127,23 +127,29 @@ class TALGenerator: ...@@ -127,23 +127,29 @@ class TALGenerator:
item = program[cursor] item = program[cursor]
except IndexError: except IndexError:
item = (None, None) item = (None, None)
if item[0] == "rawtext": opcode = item[0]
if opcode == "rawtext":
collect.append(item[1]) collect.append(item[1])
continue continue
if item[0] == "endTag": if opcode == "endTag":
collect.append("</%s>" % item[1]) collect.append("</%s>" % item[1])
continue continue
if item[0] == "startTag": if opcode == "startTag":
if self.optimizeStartTag(collect, item[1], item[2], ">"): if self.optimizeStartTag(collect, item[1], item[2], ">"):
continue continue
if item[0] == "startEndTag": if opcode == "startEndTag":
if self.optimizeStartTag(collect, item[1], item[2], endsep): if self.optimizeStartTag(collect, item[1], item[2], endsep):
continue continue
text = string.join(collect, "") text = string.join(collect, "")
if text: if text:
output.append(("rawtext", text)) i = string.rfind(text, "\n")
if item[0] != None: if i >= 0:
output.append(item) i = len(text) - (i + 1)
output.append(("rawtextColumn", (text, i)))
else:
output.append(("rawtextOffset", (text, len(text))))
if opcode != None:
output.append((opcode, tuple(item[1:])))
rawseen = cursor+1 rawseen = cursor+1
collect = [] collect = []
return output return output
......
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