[Python-checkins] CVS: python/dist/src/Objects longobject.c,1.55,1.56

Guido van Rossum python-dev@python.org
Mon, 10 Apr 2000 13:32:01 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/Objects
In directory eric:/projects/python/develop/guido/src/Objects

Modified Files:
	longobject.c 
Log Message:
Simple optimization by Christian Tismer, who gives credit to Lenny
Kneler for reporting this issue: long_mult() is faster when the
smaller argument is on the left.  Swap the arguments accordingly.


Index: longobject.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/longobject.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -r1.55 -r1.56
*** longobject.c	2000/04/05 20:11:20	1.55
--- longobject.c	2000/04/10 17:31:58	1.56
***************
*** 1224,1227 ****
--- 1224,1236 ----
  	size_a = ABS(a->ob_size);
  	size_b = ABS(b->ob_size);
+ 	if (size_a > size_b) {
+ 		/* we are faster with the small object on the left */
+ 		int hold_sa = size_a;
+ 		PyLongObject *hold_a = a;
+ 		size_a = size_b;
+ 		size_b = hold_sa;
+ 		a = b;
+ 		b = hold_a;
+ 	}
  	z = _PyLong_New(size_a + size_b);
  	if (z == NULL)