From 10de8803f7a9a1c5f017f79a75a5bf3f321a0324 Mon Sep 17 00:00:00 2001 From: Etienne Kneuss Date: Tue, 27 Apr 2010 04:57:48 +0000 Subject: [PATCH] Fix #49723 (Skip seek when unnecessary) --- ext/spl/spl_iterators.c | 2 +- ext/spl/tests/bug49723.phpt | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 ext/spl/tests/bug49723.phpt diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 07f47680de..b6e2900e80 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1738,7 +1738,7 @@ static inline void spl_limit_it_seek(spl_dual_it_object *intern, long pos TSRMLS zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Cannot seek to %ld which is behind offset %ld plus count %ld", pos, intern->u.limit.offset, intern->u.limit.count); return; } - if (instanceof_function(intern->inner.ce, spl_ce_SeekableIterator TSRMLS_CC)) { + if (pos != intern->current.pos && instanceof_function(intern->inner.ce, spl_ce_SeekableIterator TSRMLS_CC)) { MAKE_STD_ZVAL(zpos); ZVAL_LONG(zpos, pos); spl_dual_it_free(intern TSRMLS_CC); diff --git a/ext/spl/tests/bug49723.phpt b/ext/spl/tests/bug49723.phpt new file mode 100644 index 0000000000..221e806611 --- /dev/null +++ b/ext/spl/tests/bug49723.phpt @@ -0,0 +1,16 @@ +--TEST-- +LimitIterator: do not seek if not needed +--FILE-- + +===DONE=== +--EXPECT-- +===DONE=== -- 2.50.1