[Python-checkins] python/dist/src/Objects dictobject.c, 2.164, 2.165

rhettinger@users.sourceforge.net rhettinger at users.sourceforge.net
Sat May 14 20:08:27 CEST 2005


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13045

Modified Files:
	dictobject.c 
Log Message:
SF patch #1200051:  Small optimization for PyDict_Merge()
(Contributed by Barry Warsaw and Matt Messier.)



Index: dictobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v
retrieving revision 2.164
retrieving revision 2.165
diff -u -d -r2.164 -r2.165
--- dictobject.c	15 Apr 2005 15:58:42 -0000	2.164
+++ dictobject.c	14 May 2005 18:08:25 -0000	2.165
@@ -1203,6 +1203,12 @@
 		if (other == mp || other->ma_used == 0)
 			/* a.update(a) or a.update({}); nothing to do */
 			return 0;
+		if (mp->ma_used == 0)
+			/* Since the target dict is empty, PyDict_GetItem()
+			 * always returns NULL.  Setting override to 1
+			 * skips the unnecessary test.
+			 */
+			override = 1;
 		/* Do one big resize at the start, rather than
 		 * incrementally resizing as we insert new items.  Expect
 		 * that there will be no (or few) overlapping keys.



More information about the Python-checkins mailing list