浏览代码

Merge branch 'github/pr/182'

Daniele Alessandri 10 年之前
父节点
当前提交
45da0fca55
共有 1 个文件被更改,包括 12 次插入10 次删除
  1. 12 10
      lib/Predis/Collection/Iterator/CursorBasedIterator.php

+ 12 - 10
lib/Predis/Collection/Iterator/CursorBasedIterator.php

@@ -165,16 +165,18 @@ abstract class CursorBasedIterator implements Iterator
      */
     public function next()
     {
-        if (!$this->elements && $this->fetchmore) {
-            $this->fetch();
-        }
-
-        if ($this->elements) {
-            $this->extractNext();
-        } elseif ($this->cursor) {
-            $this->next();
-        } else {
-            $this->valid = false;
+        tryFetch: {
+            if (!$this->elements && $this->fetchmore) {
+                $this->fetch();
+            }
+
+            if ($this->elements) {
+                $this->extractNext();
+            } elseif ($this->cursor) {
+                goto tryFetch;
+            } else {
+                $this->valid = false;
+            }
         }
     }