diff options
| author | Etienne Kneuss <colder@php.net> | 2010-04-27 04:57:48 +0000 |
|---|---|---|
| committer | Etienne Kneuss <colder@php.net> | 2010-04-27 04:57:48 +0000 |
| commit | 6f5f6d2bcad3ea41dcdc4a020d4f58beb4870a76 (patch) | |
| tree | 7857df3be65b8019678801a7a871c152a7669c64 | |
| parent | 91ee07814e582b292d1e06b208f62f4c40abaf64 (diff) | |
| download | php-git-6f5f6d2bcad3ea41dcdc4a020d4f58beb4870a76.tar.gz | |
Fix #49723 (Skip seek when unnecessary)
| -rwxr-xr-x | ext/spl/spl_iterators.c | 2 | ||||
| -rw-r--r-- | ext/spl/tests/bug49723.phpt | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 78ffb872bc..d71f4e80da 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -2080,7 +2080,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-- +<?php + +$it = new ArrayIterator(array()); + +$lit = new LimitIterator($it, 0, 5); + +foreach ($lit as $v) { + echo $v; +} +?> +===DONE=== +--EXPECT-- +===DONE=== |
