summary history branches tags files
commit:eb54f2304c48b9f092676f4b44e108f49df588e8
author:Trevor Bentley
committer:GitHub
date:Tue Aug 8 21:46:32 2017 +0200
parents:2136b09f27ce41e6650b65afd711d868a6a27412, a0ad02f6c5f621a25a673c3983bb70cf00a79721
Merge pull request #3 from mrmekon/fix_infinite_loop

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());