[Checkins] SVN: z3c.pt/trunk/ - Optimize simple case: if path expression is a single path and path
Sidnei da Silva
sidnei at enfoldsystems.com
Mon Jan 19 23:11:11 EST 2009
Log message for revision 94872:
- Optimize simple case: if path expression is a single path and path
is 'nothing' or has 'nocall:', just return value as-is, without
going through path_traverse. [sidnei]
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/expressions.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2009-01-20 01:41:04 UTC (rev 94871)
+++ z3c.pt/trunk/CHANGES.txt 2009-01-20 04:11:10 UTC (rev 94872)
@@ -3,6 +3,10 @@
In next version
+- Optimize simple case: if path expression is a single path and path
+ is 'nothing' or has 'nocall:', just return value as-is, without
+ going through path_traverse. [sidnei]
+
- Moved evaluate_path and evaluate_exists over from ``five.pt``, adds
support for global ``path()`` and ``exists()`` functions for use in
``python:`` expressions (LP #317967).
Modified: z3c.pt/trunk/src/z3c/pt/expressions.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/expressions.py 2009-01-20 01:41:04 UTC (rev 94871)
+++ z3c.pt/trunk/src/z3c/pt/expressions.py 2009-01-20 04:11:10 UTC (rev 94872)
@@ -92,6 +92,12 @@
>>> translate("") is None
True
+ >>> translate("nocall: a")
+ value('a')
+
+ >>> translate("nothing")
+ value('None')
+
>>> translate("a/b")
value("_path(a, request, True, 'b')")
@@ -162,10 +168,15 @@
components.append(component)
+ base = parts[0]
+
if not components:
- components = ()
+ if len(parts) == 1 and (nocall or base == 'None'):
+ value = types.value('%s' % base)
+ return value
+ else:
+ components = ()
- base = parts[0]
value = types.value(
'%s(%s, %s, %s, %s)' % \
(self.symbol, base, self.scope, not nocall, ', '.join(components)))
More information about the Checkins
mailing list