[Python-checkins] CVS: python/dist/src/Objects object.c,2.153,2.154
Tim Peters
tim_one@users.sourceforge.net
2001年10月06日 10:45:19 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv10405/python/Objects
Modified Files:
object.c
Log Message:
_PyObject_GetDictPtr():
+ Use the _PyObject_VAR_SIZE macro to compute object size.
+ Break the computation into lines convenient for debugger inspection.
+ Speed the round-up-to-pointer-size computation.
Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.153
retrieving revision 2.154
diff -C2 -d -r2.153 -r2.154
*** object.c 2001年10月05日 21:58:11 2.153
--- object.c 2001年10月06日 17:45:17 2.154
***************
*** 1158,1170 ****
return NULL;
if (dictoffset < 0) {
! dictoffset += tp->tp_basicsize;
! dictoffset += tp->tp_itemsize * ((PyVarObject *)obj)->ob_size;
assert(dictoffset > 0); /* Sanity check */
! /* Round up, if necessary */
! if (dictoffset % PTRSIZE != 0) {
! dictoffset /= PTRSIZE;
! dictoffset += 1;
! dictoffset *= PTRSIZE;
! }
}
return (PyObject **) ((char *)obj + dictoffset);
--- 1158,1174 ----
return NULL;
if (dictoffset < 0) {
! /* dictoffset is positive by the time we're ready to round
! it, and compilers can generate faster rounding code if
! they know that. */
! unsigned long udo; /* unsigned dictoffset */
! const long nitems = ((PyVarObject *)obj)->ob_size;
! const long size = _PyObject_VAR_SIZE(tp, nitems);
!
! dictoffset += size;
assert(dictoffset > 0); /* Sanity check */
! /* Round up to multiple of PTRSIZE. */
! udo = (unsigned long)dictoffset;
! udo = ((udo + PTRSIZE-1) / PTRSIZE) * PTRSIZE;
! dictoffset = (long)udo;
}
return (PyObject **) ((char *)obj + dictoffset);