summary history branches tags files
commit:a0ad02f6c5f621a25a673c3983bb70cf00a79721
author:Trevor Bentley
committer:Trevor Bentley
date:Tue Aug 8 19:28:26 2017 +0200
parents:2136b09f27ce41e6650b65afd711d868a6a27412
Fix infinite loop bug that caused it to peg to 100% CPU and hang
diff --git a/src/lib.rs b/src/lib.rs
line changes: +1/-1
index 938ac2d..1d8bfa8
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -168,9 +168,9 @@ impl<'a> Iterator for HackerNewsIterator<'a> {
         let reader = self.hn.top.read().unwrap();
         while self.idx < reader.len() {
             let item: Option<&u64> = (*reader).get(self.idx);
+            self.idx += 1;
             if let Some(item) = item {
                 if let Some(item) = self.hn.cache.write().unwrap().get_mut(item) {
-                    self.idx += 1;
                     if !item.hidden {
                         item.seen = true;
                         return Some((*item).clone());