From 20d7b4ff26b04fcc127544345a9e8c81cade0f69 Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Sun, 31 Aug 2003 20:08:14 +0000 Subject: [PATCH] - sort cache before saveing (I think this will make reading it less memory consuming and a bit faster) - should fix "strange things going on" problem (not sure though) --- trunk/ripnews/news/article.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/trunk/ripnews/news/article.rb b/trunk/ripnews/news/article.rb index 2ffee8f..24364ad 100644 --- a/trunk/ripnews/news/article.rb +++ b/trunk/ripnews/news/article.rb @@ -1,4 +1,4 @@ -# $Dwarf: article.rb,v 1.76 2003/08/18 22:14:02 ward Exp $ +# $Dwarf: article.rb,v 1.77 2003/08/31 17:30:13 ward Exp $ # $Source$ # @@ -563,17 +563,17 @@ def save_cache(cachedir, server) if FileTest.directory?( cachedir ) file = File.new( "#{filename}.#{server}.new", "w" ) or print "couldn't open cachefile for writing\n" print "Updating cache...\n" -# cache = [] -# for i in (0...@subjects.length) -# cache.push("#{@ids[i]}|#{@messids[i]}|#{@servers[i]}|#{@subjects[i]}\n") -# end -# cache.sort! -# file.print cache + cache = [] for i in (0...@subjects.length) - if @servers[i] == server - file.print "#{@ids[i]}|#{@messids[i]}|#{@subjects[i]}\n" - end + cache.push("#{@ids[i]}|#{@messids[i]}|#{@subjects[i]}\n") if @servers[i] == server end + cache.sort! + file.print cache +# for i in (0...@subjects.length) +# if @servers[i] == server +# file.print "#{@ids[i]}|#{@messids[i]}|#{@subjects[i]}\n" +# end +# end file.close if ( File.move("#{filename}.#{server}.new", "#{filename}.#{server}") ) print "Cache updated for #{server}\n" @@ -617,7 +617,7 @@ def group_subject_sort(subj) @groups[subj]["messages"][i].dup, @groups[subj]["ids"][i].dup, @groups[subj]["servers"][i].dup - ] ) + ] ) if serverhash[@groups[subj]["servers"][i]] != nil end sort_arr.sort!{|a,b| r = ward_sort(a[0], b[0])