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