[Zope3-checkins] CVS: Zope3/src/zope/tal - talinterpreter.py:1.16

Fred L. Drake, Jr. fred@zope.com
Tue, 8 Apr 2003 13:01:18 -0400


Update of /cvs-repository/Zope3/src/zope/tal
In directory cvs.zope.org:/tmp/cvs-serv22000

Modified Files:
	talinterpreter.py 
Log Message:
Fold the common case for attrAction*() into do_startTag(); this is the
path taken often enough for this to really reduce the number of method
calls.


=== Zope3/src/zope/tal/talinterpreter.py 1.15 => 1.16 ===
--- Zope3/src/zope/tal/talinterpreter.py:1.15	Tue Apr  8 11:40:44 2003
+++ Zope3/src/zope/tal/talinterpreter.py	Tue Apr  8 13:01:17 2003
@@ -265,7 +265,13 @@
                 if _len(item) == 2:
                     name, s = item
                 else:
-                    ok, name, s = attrAction(self, item)
+                    # item[2] is the 'action' field:
+                    if item[2] in ('metal', 'tal', 'xmlns', 'i18n'):
+                        if not self.showtal:
+                            continue
+                        ok, name, s = self.attrAction(item)
+                    else:
+                        ok, name, s = attrAction(self, item)
                     if not ok:
                         continue
                 slen = _len(s)
@@ -288,8 +294,7 @@
 
     def attrAction(self, item):
         name, value, action = item[:3]
-        if action == 'insert' or (action in ('metal', 'tal', 'xmlns', 'i18n')
-                                  and not self.showtal):
+        if action == 'insert':
             return 0, name, value
         macs = self.macroStack
         if action == 'metal' and self.metal and macs:
@@ -320,14 +325,6 @@
 
     def attrAction_tal(self, item):
         name, value, action = item[:3]
-        if action in ('metal', 'tal', 'xmlns', 'i18n'):
-            if not self.showtal:
-                # This shortcuts a common case that's also handled by
-                # the short path in .attrAction(); this avoids a
-                # method call that gets called too often.
-                return 0, name, value
-            else:
-                return self.attrAction(item)
         ok = 1
         expr, xlat, msgid = item[3:]
         if self.html and name.lower() in BOOLEAN_HTML_ATTRS: