[Python-checkins] python/dist/src/Modules itertoolsmodule.c,1.6,1.7

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
2003年2月28日 17:48:26 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv883
Modified Files:
	itertoolsmodule.c 
Log Message:
Several of the tools can make direct calls the inner iterators.
Index: itertoolsmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/itertoolsmodule.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** itertoolsmodule.c	23 Feb 2003 04:40:07 -0000	1.6
--- itertoolsmodule.c	1 Mar 2003 01:48:24 -0000	1.7
***************
*** 236,243 ****
 {
 	PyObject *item, *good;
 	long ok;
 
 	for (;;) {
! 		item = PyIter_Next(lz->it);
 		if (item == NULL)
 			return NULL;
--- 236,245 ----
 {
 	PyObject *item, *good;
+ 	PyObject *it = lz->it;
 	long ok;
 
 	for (;;) {
! 		assert(PyIter_Check(it));
! 		item = (*it->ob_type->tp_iternext)(it);
 		if (item == NULL)
 			return NULL;
***************
*** 390,393 ****
--- 392,396 ----
 {
 	PyObject *item, *good;
+ 	PyObject *it = lz->it;
 	long ok;
 
***************
*** 395,399 ****
 		return NULL;
 
! 	item = PyIter_Next(lz->it);
 	if (item == NULL)
 		return NULL;
--- 398,403 ----
 		return NULL;
 
! 	assert(PyIter_Check(it));
! 	item = (*it->ob_type->tp_iternext)(it);
 	if (item == NULL)
 		return NULL;
***************
*** 561,568 ****
 {
 	PyObject *item;
 	long oldnext;
 
 	while (lz->cnt < lz->next) {
! 		item = PyIter_Next(lz->it);
 		if (item == NULL)
 			return NULL;
--- 565,574 ----
 {
 	PyObject *item;
+ 	PyObject *it = lz->it;
 	long oldnext;
 
 	while (lz->cnt < lz->next) {
! 		assert(PyIter_Check(it));
! 		item = (*it->ob_type->tp_iternext)(it);
 		if (item == NULL)
 			return NULL;
***************
*** 572,576 ****
 	if (lz->cnt >= lz->stop)
 		return NULL;
! 	item = PyIter_Next(lz->it);
 	if (item == NULL)
 		return NULL;
--- 578,583 ----
 	if (lz->cnt >= lz->stop)
 		return NULL;
! 	assert(PyIter_Check(it));
! 	item = (*it->ob_type->tp_iternext)(it);
 	if (item == NULL)
 		return NULL;
***************
*** 716,721 ****
 	PyObject *args;
 	PyObject *result;
 
! 	args = PyIter_Next(lz->it);
 	if (args == NULL)
 		return NULL;
--- 723,730 ----
 	PyObject *args;
 	PyObject *result;
+ 	PyObject *it = lz->it;
 
! 	assert(PyIter_Check(it));
! 	args = (*it->ob_type->tp_iternext)(it);
 	if (args == NULL)
 		return NULL;
***************
*** 1195,1202 ****
 {
 	PyObject *item;
 	long ok;
 
 	for (;;) {
! 		item = PyIter_Next(lz->it);
 		if (item == NULL)
 			return NULL;
--- 1204,1213 ----
 {
 	PyObject *item;
+ 	PyObject *it = lz->it;
 	long ok;
 
 	for (;;) {
! 		assert(PyIter_Check(it));
! 		item = (*it->ob_type->tp_iternext)(it);
 		if (item == NULL)
 			return NULL;
***************
*** 1349,1356 ****
 {
 	PyObject *item;
 	long ok;
 
 	for (;;) {
! 		item = PyIter_Next(lz->it);
 		if (item == NULL)
 			return NULL;
--- 1360,1369 ----
 {
 	PyObject *item;
+ 	PyObject *it = lz->it;
 	long ok;
 
 	for (;;) {
! 		assert(PyIter_Check(it));
! 		item = (*it->ob_type->tp_iternext)(it);
 		if (item == NULL)
 			return NULL;
***************
*** 1627,1631 ****
 		for (i=0 ; i < tuplesize ; i++) {
 			it = PyTuple_GET_ITEM(lz->ittuple, i);
! 			item = PyIter_Next(it);
 			if (item == NULL)
 				return NULL;
--- 1640,1645 ----
 		for (i=0 ; i < tuplesize ; i++) {
 			it = PyTuple_GET_ITEM(lz->ittuple, i);
! 			assert(PyIter_Check(it));
! 			item = (*it->ob_type->tp_iternext)(it);
 			if (item == NULL)
 				return NULL;
***************
*** 1640,1644 ****
 		for (i=0 ; i < tuplesize ; i++) {
 			it = PyTuple_GET_ITEM(lz->ittuple, i);
! 			item = PyIter_Next(it);
 			if (item == NULL) {
 				Py_DECREF(result);
--- 1654,1659 ----
 		for (i=0 ; i < tuplesize ; i++) {
 			it = PyTuple_GET_ITEM(lz->ittuple, i);
! 			assert(PyIter_Check(it));
! 			item = (*it->ob_type->tp_iternext)(it);
 			if (item == NULL) {
 				Py_DECREF(result);

AltStyle によって変換されたページ (->オリジナル) /