some speed ups
This commit is contained in:
parent
f4ab55fdf0
commit
e827c94393
1 changed files with 18 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
# $Dwarf: article.rb,v 1.111 2005/03/06 07:01:08 ward Exp $
|
# $Dwarf: article.rb,v 1.112 2005/03/06 11:14:28 ward Exp $
|
||||||
# $Source$
|
# $Source$
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -90,6 +90,8 @@ private :sendka
|
||||||
end # class KANNTP
|
end # class KANNTP
|
||||||
end # module Net
|
end # module Net
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
|
||||||
class Article
|
class Article
|
||||||
|
|
||||||
Debuglevel = 1
|
Debuglevel = 1
|
||||||
|
|
@ -197,7 +199,7 @@ def preselect(subject)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add(id, messid, subject, server)
|
def add(id, messid, subject, server)
|
||||||
@messageinfo.push(Message.new(messid, id.to_i, server, subject))
|
@messageinfo.push(Message.new(messid, id, server, subject))
|
||||||
@grouped = false
|
@grouped = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -305,7 +307,7 @@ def get_articles(cachedir=false)
|
||||||
# en anders een leuk regeltje aan de cache toevoegen,
|
# en anders een leuk regeltje aan de cache toevoegen,
|
||||||
# maar niet in het geheugen houden
|
# maar niet in het geheugen houden
|
||||||
if preselect(art[id]["subject"])
|
if preselect(art[id]["subject"])
|
||||||
add(id, art[id]["messid"], art[id]["subject"], server)
|
add(id.to_i, art[id]["messid"], art[id]["subject"], server)
|
||||||
end
|
end
|
||||||
cache_add(cachedir, id, art[id]["messid"], art[id]["subject"], server)
|
cache_add(cachedir, id, art[id]["messid"], art[id]["subject"], server)
|
||||||
end
|
end
|
||||||
|
|
@ -651,7 +653,10 @@ def group_subjects
|
||||||
@groups = {}
|
@groups = {}
|
||||||
for i in (0...@messageinfo.length)
|
for i in (0...@messageinfo.length)
|
||||||
print "group subjects: #{i} #{@messageinfo[i][:subject]}\n" if Debuglevel > 3
|
print "group subjects: #{i} #{@messageinfo[i][:subject]}\n" if Debuglevel > 3
|
||||||
|
# misschien is het wel belangrijk dat er voorkeuren in deze
|
||||||
|
# match zitten... geen idee
|
||||||
if @messageinfo[i][:subject] =~ /(.*)\((\d+)\/(\d+)\)(.*)/ || @messageinfo[i][:subject] =~ /(.*)\[(\d+)\/(\d+)\](.*)/
|
if @messageinfo[i][:subject] =~ /(.*)\((\d+)\/(\d+)\)(.*)/ || @messageinfo[i][:subject] =~ /(.*)\[(\d+)\/(\d+)\](.*)/
|
||||||
|
#if @messageinfo[i][:subject] =~ /(.*)[\(\[](\d+)\/(\d+)[\)\]](.*)/
|
||||||
j = "#{$1}#{$4} (#{$3})"
|
j = "#{$1}#{$4} (#{$3})"
|
||||||
number = $2
|
number = $2
|
||||||
total = $3
|
total = $3
|
||||||
|
|
@ -673,7 +678,7 @@ end
|
||||||
|
|
||||||
def set_skip_ids(server, ids)
|
def set_skip_ids(server, ids)
|
||||||
set = Set::IntSpan.new(ids)
|
set = Set::IntSpan.new(ids)
|
||||||
set.finite or return false
|
set.finite? or return false
|
||||||
min = set.min
|
min = set.min
|
||||||
min != nil and min < 0 and return false
|
min != nil and min < 0 and return false
|
||||||
@connections[server]["skip_ids"] = set
|
@connections[server]["skip_ids"] = set
|
||||||
|
|
@ -717,7 +722,10 @@ p "reading & scrubbing cache"
|
||||||
p Time.now
|
p Time.now
|
||||||
filename = "#{cachedir}/#{@group}.ripnewscache"
|
filename = "#{cachedir}/#{@group}.ripnewscache"
|
||||||
excludes = {}
|
excludes = {}
|
||||||
|
regexp = Regexp.new('^([^\|]*)\|([^\|]*)\|(.*)')
|
||||||
for server in @connections.keys
|
for server in @connections.keys
|
||||||
|
first = @connections[server]["first"]
|
||||||
|
last = @connections[server]["last"]
|
||||||
#cache_scrub(cachedir, server)
|
#cache_scrub(cachedir, server)
|
||||||
puts " reading cache for #{server}"
|
puts " reading cache for #{server}"
|
||||||
puts " #{Time.now}"
|
puts " #{Time.now}"
|
||||||
|
|
@ -726,15 +734,17 @@ puts " #{Time.now}"
|
||||||
if FileTest.directory?( cachedir) and FileTest.file?( "#{filename}.#{server}" ) and FileTest.readable?( "#{filename}.#{server}" )
|
if FileTest.directory?( cachedir) and FileTest.file?( "#{filename}.#{server}" ) and FileTest.readable?( "#{filename}.#{server}" )
|
||||||
outfile = File.new("#{filename}.#{server}.new", "w") or puts "Couldn't open cachefile for writing"
|
outfile = File.new("#{filename}.#{server}.new", "w") or puts "Couldn't open cachefile for writing"
|
||||||
File.new( "#{filename}.#{server}" ).each{ |line|
|
File.new( "#{filename}.#{server}" ).each{ |line|
|
||||||
id, messid, subject = line.split("|", 3)
|
line =~ regexp
|
||||||
id_i = id.to_i
|
id_i = $1.to_i
|
||||||
if id_i >= @connections[server]["first"] and
|
messid = $2
|
||||||
id_i <= @connections[server]["last"]
|
subject = $3
|
||||||
|
if first <= id_i and id_i <= last
|
||||||
outfile.puts(line)
|
outfile.puts(line)
|
||||||
unless excludes[server].has_key?(id_i)
|
unless excludes[server].has_key?(id_i)
|
||||||
if preselect(subject)
|
if preselect(subject)
|
||||||
add(id_i, messid, subject, server)
|
add(id_i, messid, subject, server)
|
||||||
end
|
end
|
||||||
|
# XXX alle traagheid van de cache_read zit in deze regel:
|
||||||
@connections[server]["skip_ids"].insert(id_i)
|
@connections[server]["skip_ids"].insert(id_i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue