[Python-checkins] python/dist/src/Objects stringobject.c,2.202,2.203
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Mon, 06 Jan 2003 14:42:45 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv23816
Modified Files:
stringobject.c
Log Message:
GvR's idea to use memset() for the most common special case of repeating
a single character. Shaves another 10% off the running time by avoiding
the lg2(N) loops and cache effects for the other cases.
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.202
retrieving revision 2.203
diff -C2 -d -r2.202 -r2.203
*** stringobject.c 6 Jan 2003 10:33:56 -0000 2.202
--- stringobject.c 6 Jan 2003 22:42:41 -0000 2.203
***************
*** 967,970 ****
--- 967,975 ----
op->ob_shash = -1;
op->ob_sstate = SSTATE_NOT_INTERNED;
+ op->ob_sval[size] = '\0';
+ if (a->ob_size == 1 && n > 0) {
+ memset(op->ob_sval, a->ob_sval[0] , n);
+ return (PyObject *) op;
+ }
i = 0;
if (i < size) {
***************
*** 977,981 ****
i += j;
}
- op->ob_sval[size] = '\0';
return (PyObject *) op;
}
--- 982,985 ----