[Python-checkins] python/dist/src/Objects longobject.c,1.153,1.154

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sun, 02 Feb 2003 09:33:55 -0800


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv26400/Objects

Modified Files:
	longobject.c 
Log Message:
long_from_binary_base():  Sped this a little by computing the # of bits
needed outside the first loop.


Index: longobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -C2 -d -r1.153 -r1.154
*** longobject.c	2 Feb 2003 08:05:32 -0000	1.153
--- longobject.c	2 Feb 2003 17:33:53 -0000	1.154
***************
*** 1127,1139 ****
  		if (k < 0 || k >= base)
  			break;
- 		n += bits_per_char;
- 		if (n < 0) {
- 			PyErr_SetString(PyExc_ValueError,
- 					"long string too large to convert");
- 			return NULL;
- 		}
  		++p;
  	}
  	*str = p;
  	/* n <- # of Python digits needed, = ceiling(n/SHIFT). */
  	n = (n + SHIFT - 1) / SHIFT;
--- 1127,1139 ----
  		if (k < 0 || k >= base)
  			break;
  		++p;
  	}
  	*str = p;
+ 	n = (p - start) * bits_per_char;
+ 	if (n / bits_per_char != p - start) {
+ 		PyErr_SetString(PyExc_ValueError,
+ 				"long string too large to convert");
+ 		return NULL;
+ 	}
  	/* n <- # of Python digits needed, = ceiling(n/SHIFT). */
  	n = (n + SHIFT - 1) / SHIFT;