From af30942d60a2cac3655cb2a10ed5a01e370c7807 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 5 Jan 2014 10:43:27 -0700 Subject: [PATCH] Reduce unnecessary usage of RAL.splice --- src/General/lib/randomaccesslist.class | 3 +-- src/Monitoring/Unread.coffee | 11 ++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/General/lib/randomaccesslist.class b/src/General/lib/randomaccesslist.class index 902f13fc3..aa736e33f 100644 --- a/src/General/lib/randomaccesslist.class +++ b/src/General/lib/randomaccesslist.class @@ -19,14 +19,13 @@ class RandomAccessList @rmi item {next} = root - next.prev = root.next = item item.prev = root item.next = next shift: -> @rm @first.ID - + splice: (start, end) -> return unless @[end] cur = if start is 0 then @first else @[start] diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index c31bf41ba..c6fcf81f9 100755 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -56,15 +56,12 @@ Unread = defaultValue: 0 return unless Unread.lastReadPost < lastReadPost Unread.lastReadPost = lastReadPost - Unread.readArray Unread.posts post = Unread.posts.first while post - break if post.ID > Unread.lastReadPost - {ID} = post - break unless post.next + break if ({ID} = post) > Unread.lastReadPost post = post.next - Unread.posts.splice 0, ID + Unread.posts.rm ID Unread.readArray Unread.postsQuotingYou Unread.setLine() if Conf['Unread Line'] @@ -125,7 +122,7 @@ Unread = readSinglePost: (post) -> {ID} = post return unless Unread.posts[ID] - Unread.posts.splice ID post.next.ID + Unread.posts.rm ID if post is Unread.posts.first Unread.lastReadPost = ID Unread.saveLastReadPost() @@ -152,12 +149,12 @@ Unread = if post.info.yours QuoteYou.lastRead = post.nodes.root post = post.next + posts.rm ID else break return unless ID - posts.splice 0, ID Unread.lastReadPost = ID if Unread.lastReadPost < ID or !Unread.lastReadPost Unread.saveLastReadPost() Unread.readArray Unread.postsQuotingYou