[Checkins] SVN: z3c.pt/trunk/ Avoid string concatenation and use multiple write statements instead. These are faster now, since we use a list append internally.

Hanno Schlichting plone at hannosch.info
Wed Jul 23 03:41:06 EDT 2008


Log message for revision 88746:
  Avoid string concatenation and use multiple write statements instead. These are faster now, since we use a list append internally.
  

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  U   z3c.pt/trunk/src/z3c/pt/clauses.py

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2008-07-23 04:44:56 UTC (rev 88745)
+++ z3c.pt/trunk/CHANGES.txt	2008-07-23 07:41:04 UTC (rev 88746)
@@ -4,6 +4,10 @@
 Version 0.8.x
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+- Avoid string concatenation and use multiple write statements instead. These
+  are faster now, since we use a list append internally.
+  [hannosch]
+
 - Inline the _escape function, because function calls are expensive in Python.
   Added missing escaping for Unicode values.
   [fschulze, hannosch]

Modified: z3c.pt/trunk/src/z3c/pt/clauses.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/clauses.py	2008-07-23 04:44:56 UTC (rev 88745)
+++ z3c.pt/trunk/src/z3c/pt/clauses.py	2008-07-23 07:41:04 UTC (rev 88746)
@@ -504,19 +504,22 @@
             if unicode_required_flag:
                 stream.write("if isinstance(%s, unicode):" % temp)
                 stream.indent()
-                stream.write("_write(' %s=\"'+_escape(%s,1,0)+'\"')" %
-                             (attribute, temp))
+                stream.write("_write(' %s=\"')" % attribute)
+                stream.write("_write(_escape(%s,1,0))" % temp)
+                stream.write("_write('\"')")
                 stream.outdent()
                 stream.write("elif %s is not None:" % temp)
                 stream.indent()
-                stream.write("_write(' %s=\"'+_escape(%s,1)+'\"')" %
-                             (attribute, temp))
+                stream.write("_write(' %s=\"')" % attribute)
+                stream.write("_write(_escape(%s,1))" % temp)
+                stream.write("_write('\"')")
                 stream.outdent()
             else:
                 stream.write("if %s is not None:" % temp)
                 stream.indent()
-                stream.write("_write(' %s=\"'+_escape(%s,1)+'\"')" %
-                             (attribute, temp))
+                stream.write("_write(' %s=\"')" % attribute)
+                stream.write("_write(_escape(%s,1))" % temp)
+                stream.write("_write('\"')")
                 stream.outdent()
 
             assign.end(stream)



More information about the Checkins mailing list