remove linked list stuff from Index

This commit is contained in:
ccd0 2014-09-05 19:57:00 -07:00
parent 8f2f1aa536
commit a37da6527f

View File

@ -379,12 +379,12 @@ Index =
replycount: [liveThreadData...].sort((a, b) -> b.replies - a.replies).map (post) -> post.no replycount: [liveThreadData...].sort((a, b) -> b.replies - a.replies).map (post) -> post.no
filecount: [liveThreadData...].sort((a, b) -> b.images - a.images ).map (post) -> post.no filecount: [liveThreadData...].sort((a, b) -> b.images - a.images ).map (post) -> post.no
}[Conf['Index Sort']] }[Conf['Index Sort']]
Index.sortedNodes = sortedNodes = new RandomAccessList Index.sortedNodes = sortedNodes = []
{nodes} = Index {nodes} = Index
for threadID in sortedThreadIDs for threadID in sortedThreadIDs
sortedNodes.push nodes[Index.liveThreadIDs.indexOf(threadID)] sortedNodes.push nodes[Index.liveThreadIDs.indexOf(threadID)]
if Index.isSearching and nodes = Index.querySearch(Index.searchInput.value) if Index.isSearching and nodes = Index.querySearch(Index.searchInput.value)
Index.sortedNodes = new RandomAccessList nodes Index.sortedNodes = nodes
items = [ items = [
# Sticky threads # Sticky threads
fn: (thread) -> thread.isSticky fn: (thread) -> thread.isSticky
@ -403,41 +403,26 @@ Index =
return return
sortOnTop: (match) -> sortOnTop: (match) ->
{sortedNodes} = Index topNodes = []
threadRoot = target = sortedNodes.first bottomNodes = []
while threadRoot for threadRoot in Index.sortedNodes
{next} = threadRoot (if match Get.threadFromRoot threadRoot then topNodes else bottomNodes).push threadRoot
if match Get.threadFromRoot threadRoot.data Index.sortedNodes = topNodes.concat(bottomNodes)
if threadRoot is target
target = target.next
else
sortedNodes.before target, threadRoot
threadRoot = next
return
buildIndex: -> buildIndex: ->
if Conf['Index Mode'] isnt 'all pages' if Conf['Index Mode'] isnt 'all pages'
nodes = Index.buildSinglePage Index.getCurrentPage() nodes = Index.buildSinglePage Index.getCurrentPage()
else else
nodes = [(target = Index.sortedNodes.first).data] nodes = Index.sortedNodes
while target = target.next
nodes.push target.data
$.rmAll Index.root $.rmAll Index.root
$.rmAll Header.hover $.rmAll Header.hover
Index.buildReplies nodes if Conf['Show Replies'] Index.buildReplies nodes if Conf['Show Replies']
Index.buildStructure nodes Index.buildStructure nodes
buildSinglePage: (pageNum) -> buildSinglePage: (pageNum) ->
nodes = []
nodesPerPage = Index.threadsNumPerPage nodesPerPage = Index.threadsNumPerPage
offset = nodesPerPage * (pageNum - 1) offset = nodesPerPage * (pageNum - 1)
end = offset + nodesPerPage Index.sortedNodes.slice offset, offset + nodesPerPage
target = Index.sortedNodes.order()[offset]
Index.sortedNodes
while (offset++ <= end) and target
nodes.push target.data
target = target.next
nodes
buildStructure: (nodes) -> buildStructure: (nodes) ->
for node in nodes for node in nodes
@ -485,14 +470,8 @@ Index =
Index.search keywords Index.search keywords
search: (keywords) -> search: (keywords) ->
found = [] Index.sortedNodes.filter (threadRoot) ->
target = Index.sortedNodes.first Index.searchMatch Get.threadFromRoot(threadRoot), keywords
while target
{data} = target
if Index.searchMatch Get.threadFromRoot(data), keywords
found.push data
target = target.next
found
searchMatch: (thread, keywords) -> searchMatch: (thread, keywords) ->
{info, file} = thread.OP {info, file} = thread.OP