From a02d064ad6bcbe8d2148c986feb9c9f5aab47a0a Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Mon, 14 Jun 2004 09:14:48 +0000 Subject: [PATCH] some performance improvements git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5982 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Lib/common.swg | 8 ++++---- SWIG/Lib/python/pyrun.swg | 12 ++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/SWIG/Lib/common.swg b/SWIG/Lib/common.swg index 5d5617522..847014b6a 100644 --- a/SWIG/Lib/common.swg +++ b/SWIG/Lib/common.swg @@ -261,10 +261,10 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { SWIGRUNTIME(char *) SWIG_PackData(char *c, void *ptr, int sz) { static char hex[17] = "0123456789abcdef"; - int i; unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; register unsigned char uu; - for (i = 0; i < sz; i++,u++) { + for (; u != eu; ++u) { uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; @@ -278,8 +278,8 @@ SWIG_UnpackData(char *c, void *ptr, int sz) { register unsigned char uu = 0; register int d; unsigned char *u = (unsigned char *) ptr; - int i; - for (i = 0; i < sz; i++, u++) { + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { d = *(c++); if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); diff --git a/SWIG/Lib/python/pyrun.swg b/SWIG/Lib/python/pyrun.swg index c9aed5d7b..66c78e6ef 100644 --- a/SWIG/Lib/python/pyrun.swg +++ b/SWIG/Lib/python/pyrun.swg @@ -268,7 +268,7 @@ SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) goto type_error; } } - c = PyString_AsString(obj); + c = PyString_AS_STRING(obj); /* Pointer values must start with leading underscore */ if (*c != '_') { *ptr = (void *) 0; @@ -296,9 +296,7 @@ cobject: } if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { - PyObject *zero = PyInt_FromLong(0); - PyObject_SetAttrString(pyobj,(char*)"thisown",zero); - Py_DECREF(zero); + PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); } return 0; @@ -331,7 +329,7 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, int sz, swig_type_info *ty, char *c = 0; if ((!obj) || (!PyString_Check(obj))) goto type_error; - c = PyString_AsString(obj); + c = PyString_AS_STRING(obj); /* Pointer values must start with leading underscore */ if (*c != '_') goto type_error; c++; @@ -385,9 +383,7 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { Py_DECREF(args); if (inst) { if (own) { - PyObject *n = PyInt_FromLong(1); - PyObject_SetAttrString(inst,(char*)"thisown",n); - Py_DECREF(n); + PyObject_SetAttrString(inst,(char*)"thisown",Py_True); } robj = inst; }