From 482f6444fe3fc3a412cad9a4f5a9031d5cca5de1 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 5 Jan 2014 10:25:47 -0700 Subject: [PATCH] Logic fail. Also, why did cur work when it should have been cur.ID? --- builds/4chan-X.user.js | 11 +++++++---- builds/crx/script.js | 11 +++++++---- src/General/lib/randomaccesslist.class | 9 ++++++--- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 1b2782cb3..d2471009c 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1500,11 +1500,12 @@ return; } cur = start === 0 ? this.first : this[start]; - while (cur !== this[end]) { - if (!(next = cur.next, cur)) { + while (cur) { + next = cur.next; + this.rm(cur.ID); + if (!next || cur.ID === end) { return; } - this.rm(cur); cur = next; } }; @@ -1517,7 +1518,9 @@ } delete this[ID]; this.length--; - return this.rmi(item); + this.rmi(item); + delete item.next; + return delete item.previous; }; RandomAccessList.prototype.rmi = function(item) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 65bb931e7..c42619d77 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1506,11 +1506,12 @@ return; } cur = start === 0 ? this.first : this[start]; - while (cur !== this[end]) { - if (!(next = cur.next, cur)) { + while (cur) { + next = cur.next; + this.rm(cur.ID); + if (!next || cur.ID === end) { return; } - this.rm(cur); cur = next; } }; @@ -1523,7 +1524,9 @@ } delete this[ID]; this.length--; - return this.rmi(item); + this.rmi(item); + delete item.next; + return delete item.previous; }; RandomAccessList.prototype.rmi = function(item) { diff --git a/src/General/lib/randomaccesslist.class b/src/General/lib/randomaccesslist.class index c53a0c932..0a3de2f0c 100644 --- a/src/General/lib/randomaccesslist.class +++ b/src/General/lib/randomaccesslist.class @@ -34,9 +34,10 @@ class RandomAccessList splice: (start, end) -> return unless @[end] cur = if start is 0 then @first else @[start] - while cur isnt @[end] - return unless {next} = cur - @rm cur + while cur + {next} = cur + @rm cur.ID + return if not next or cur.ID is end cur = next rm: (ID) -> @@ -45,6 +46,8 @@ class RandomAccessList delete @[ID] @length-- @rmi item + delete item.next + delete item.previous rmi: (item) -> {prev, next} = item