[Python-checkins] r43145 - in python/trunk: Modules/stropmodule.c Objects/classobject.c Objects/frameobject.c Objects/stringobject.c Parser/tokenizer.c Python/import.c Python/traceback.c
neal.norwitz
python-checkins at python.org
Mon Mar 20 02:53:26 CET 2006
Author: neal.norwitz
Date: Mon Mar 20 02:53:23 2006
New Revision: 43145
Modified:
python/trunk/Modules/stropmodule.c
python/trunk/Objects/classobject.c
python/trunk/Objects/frameobject.c
python/trunk/Objects/stringobject.c
python/trunk/Parser/tokenizer.c
python/trunk/Python/import.c
python/trunk/Python/traceback.c
Log:
Use macro versions instead of function versions when we already know the type.
This will hopefully get rid of some Coverity warnings, be a hint to
developers, and be marginally faster.
Some asserts were added when the type is currently known, but depends
on values from another function.
Modified: python/trunk/Modules/stropmodule.c
==============================================================================
--- python/trunk/Modules/stropmodule.c (original)
+++ python/trunk/Modules/stropmodule.c Mon Mar 20 02:53:23 2006
@@ -942,7 +942,7 @@
}
table = table1;
- inlen = PyString_Size(input_obj);
+ inlen = PyString_GET_SIZE(input_obj);
result = PyString_FromStringAndSize((char *)NULL, inlen);
if (result == NULL)
return NULL;
Modified: python/trunk/Objects/classobject.c
==============================================================================
--- python/trunk/Objects/classobject.c (original)
+++ python/trunk/Objects/classobject.c Mon Mar 20 02:53:23 2006
@@ -388,15 +388,15 @@
Py_INCREF(name);
return name;
}
- m = PyString_Size(mod);
- n = PyString_Size(name);
+ m = PyString_GET_SIZE(mod);
+ n = PyString_GET_SIZE(name);
res = PyString_FromStringAndSize((char *)NULL, m+1+n);
if (res != NULL) {
- char *s = PyString_AsString(res);
- memcpy(s, PyString_AsString(mod), m);
+ char *s = PyString_AS_STRING(res);
+ memcpy(s, PyString_AS_STRING(mod), m);
s += m;
*s++ = '.';
- memcpy(s, PyString_AsString(name), n);
+ memcpy(s, PyString_AS_STRING(name), n);
}
return res;
}
Modified: python/trunk/Objects/frameobject.c
==============================================================================
--- python/trunk/Objects/frameobject.c (original)
+++ python/trunk/Objects/frameobject.c Mon Mar 20 02:53:23 2006
@@ -749,7 +749,7 @@
return;
PyErr_Fetch(&error_type, &error_value, &error_traceback);
fast = f->f_localsplus;
- j = PyTuple_Size(map);
+ j = PyTuple_GET_SIZE(map);
if (j > f->f_nlocals)
j = f->f_nlocals;
if (f->f_nlocals)
@@ -787,7 +787,7 @@
return;
PyErr_Fetch(&error_type, &error_value, &error_traceback);
fast = f->f_localsplus;
- j = PyTuple_Size(map);
+ j = PyTuple_GET_SIZE(map);
if (j > f->f_nlocals)
j = f->f_nlocals;
if (f->f_nlocals)
Modified: python/trunk/Objects/stringobject.c
==============================================================================
--- python/trunk/Objects/stringobject.c (original)
+++ python/trunk/Objects/stringobject.c Mon Mar 20 02:53:23 2006
@@ -569,8 +569,9 @@
if (!w) goto failed;
/* Append bytes to output buffer. */
- r = PyString_AsString(w);
- rn = PyString_Size(w);
+ assert(PyString_Check(w));
+ r = PyString_AS_STRING(w);
+ rn = PyString_GET_SIZE(w);
memcpy(p, r, rn);
p += rn;
Py_DECREF(w);
@@ -2314,12 +2315,12 @@
}
table = table1;
- inlen = PyString_Size(input_obj);
+ inlen = PyString_GET_SIZE(input_obj);
result = PyString_FromStringAndSize((char *)NULL, inlen);
if (result == NULL)
return NULL;
output_start = output = PyString_AsString(result);
- input = PyString_AsString(input_obj);
+ input = PyString_AS_STRING(input_obj);
if (dellen == 0) {
/* If no deletions are required, use faster code */
Modified: python/trunk/Parser/tokenizer.c
==============================================================================
--- python/trunk/Parser/tokenizer.c (original)
+++ python/trunk/Parser/tokenizer.c Mon Mar 20 02:53:23 2006
@@ -711,7 +711,9 @@
if (utf8 == NULL)
goto error_clear;
- converted = new_string(PyString_AsString(utf8), PyString_Size(utf8));
+ assert(PyString_Check(utf8));
+ converted = new_string(PyString_AS_STRING(utf8),
+ PyString_GET_SIZE(utf8));
Py_DECREF(utf8);
if (converted == NULL)
goto error_nomem;
Modified: python/trunk/Python/import.c
==============================================================================
--- python/trunk/Python/import.c (original)
+++ python/trunk/Python/import.c Mon Mar 20 02:53:23 2006
@@ -1216,12 +1216,12 @@
#endif
if (!PyString_Check(v))
continue;
- len = PyString_Size(v);
+ len = PyString_GET_SIZE(v);
if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) {
Py_XDECREF(copy);
continue; /* Too long */
}
- strcpy(buf, PyString_AsString(v));
+ strcpy(buf, PyString_AS_STRING(v));
if (strlen(buf) != len) {
Py_XDECREF(copy);
continue; /* v contains '\0' */
Modified: python/trunk/Python/traceback.c
==============================================================================
--- python/trunk/Python/traceback.c (original)
+++ python/trunk/Python/traceback.c Mon Mar 20 02:53:23 2006
@@ -165,7 +165,7 @@
}
if (PyString_Check(v)) {
size_t len;
- len = PyString_Size(v);
+ len = PyString_GET_SIZE(v);
if (len + 1 + taillen >= MAXPATHLEN)
continue; /* Too long */
strcpy(namebuf, PyString_AsString(v));
More information about the Python-checkins
mailing list