Reduce unnecessary usage of RAL.splice

This commit is contained in:
Zixaphir 2014-01-05 10:43:27 -07:00
parent bb5dcaa409
commit af30942d60
2 changed files with 5 additions and 9 deletions

View File

@ -19,7 +19,6 @@ class RandomAccessList
@rmi item @rmi item
{next} = root {next} = root
next.prev = root.next = item next.prev = root.next = item
item.prev = root item.prev = root
item.next = next item.next = next

View File

@ -56,15 +56,12 @@ Unread =
defaultValue: 0 defaultValue: 0
return unless Unread.lastReadPost < lastReadPost return unless Unread.lastReadPost < lastReadPost
Unread.lastReadPost = lastReadPost Unread.lastReadPost = lastReadPost
Unread.readArray Unread.posts
post = Unread.posts.first post = Unread.posts.first
while post while post
break if post.ID > Unread.lastReadPost break if ({ID} = post) > Unread.lastReadPost
{ID} = post
break unless post.next
post = post.next post = post.next
Unread.posts.splice 0, ID Unread.posts.rm ID
Unread.readArray Unread.postsQuotingYou Unread.readArray Unread.postsQuotingYou
Unread.setLine() if Conf['Unread Line'] Unread.setLine() if Conf['Unread Line']
@ -125,7 +122,7 @@ Unread =
readSinglePost: (post) -> readSinglePost: (post) ->
{ID} = post {ID} = post
return unless Unread.posts[ID] return unless Unread.posts[ID]
Unread.posts.splice ID post.next.ID Unread.posts.rm ID
if post is Unread.posts.first if post is Unread.posts.first
Unread.lastReadPost = ID Unread.lastReadPost = ID
Unread.saveLastReadPost() Unread.saveLastReadPost()
@ -152,12 +149,12 @@ Unread =
if post.info.yours if post.info.yours
QuoteYou.lastRead = post.nodes.root QuoteYou.lastRead = post.nodes.root
post = post.next post = post.next
posts.rm ID
else else
break break
return unless ID return unless ID
posts.splice 0, ID
Unread.lastReadPost = ID if Unread.lastReadPost < ID or !Unread.lastReadPost Unread.lastReadPost = ID if Unread.lastReadPost < ID or !Unread.lastReadPost
Unread.saveLastReadPost() Unread.saveLastReadPost()
Unread.readArray Unread.postsQuotingYou Unread.readArray Unread.postsQuotingYou