[Python-checkins] cpython: Micro-optimize unicode_expandtabs(): use FILL() macro to write N spaces

victor.stinner python-checkins at python.org
Wed Feb 22 13:58:43 CET 2012


http://hg.python.org/cpython/rev/67d7f807adb4
changeset:   75171:67d7f807adb4
user:        Victor Stinner <vstinner at wyplay.com>
date:        Wed Feb 22 13:37:04 2012 +0100
summary:
  Micro-optimize unicode_expandtabs(): use FILL() macro to write N spaces

files:
  Objects/unicodeobject.c |  7 ++-----
  1 files changed, 2 insertions(+), 5 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9975,7 +9975,6 @@
     assert(_PyUnicode_CheckConsistency(u, 1));
     return u;
 }
-#undef FILL
 
 PyObject *
 PyUnicode_Splitlines(PyObject *string, int keepends)
@@ -11141,10 +11140,8 @@
             if (tabsize > 0) {
                 incr = tabsize - (line_pos % tabsize);
                 line_pos += incr;
-                while (incr--) {
-                    PyUnicode_WRITE(kind, dest_data, j, ' ');
-                    j++;
-                }
+                FILL(kind, dest_data, ' ', j, incr);
+                j += incr;
             }
         }
         else {

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list