[Python-checkins] CVS: python/dist/src/Python compile.c,2.144,2.145
Guido van Rossum
gvanrossum@users.sourceforge.net
Thu, 18 Jan 2001 16:24:08 -0800
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv31190
Modified Files:
compile.c
Log Message:
SF Patch #103250, by pj99: Optimize a strspn() out of startup.
Minor startup speedup: avoid a call to strspn().
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.144
retrieving revision 2.145
diff -C2 -r2.144 -r2.145
*** compile.c 2000/11/27 22:22:36 2.144
--- compile.c 2001/01/19 00:24:06 2.145
***************
*** 165,168 ****
--- 165,188 ----
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
+ /* all_name_chars(s): true iff all chars in s are valid NAME_CHARS */
+
+ static int
+ all_name_chars(unsigned char *s)
+ {
+ static char ok_name_char[256];
+ static unsigned char *name_chars = NAME_CHARS;
+
+ if (ok_name_char[*name_chars] == 0) {
+ unsigned char *p;
+ for (p = name_chars; *p; p++)
+ ok_name_char[*p] = 1;
+ }
+ while (*s) {
+ if (ok_name_char[*s++] == 0)
+ return 0;
+ }
+ return 1;
+ }
+
PyCodeObject *
PyCode_New(int argcount, int nlocals, int stacksize, int flags,
***************
*** 215,224 ****
for (i = PyTuple_Size(consts); --i >= 0; ) {
PyObject *v = PyTuple_GetItem(consts, i);
- char *p;
if (!PyString_Check(v))
continue;
! p = PyString_AsString(v);
! if (strspn(p, NAME_CHARS)
! != (size_t)PyString_Size(v))
continue;
PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i));
--- 235,241 ----
for (i = PyTuple_Size(consts); --i >= 0; ) {
PyObject *v = PyTuple_GetItem(consts, i);
if (!PyString_Check(v))
continue;
! if (!all_name_chars((unsigned char *)PyString_AsString(v)))
continue;
PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i));