From a32d5581b5037edf64142f81af495003ff918a2a Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Thu, 1 Aug 2002 11:50:09 +0000 Subject: [PATCH] use << when adding stuff to strings; use concat when appending arrays to arrays --- trunk/ripnews/CHANGELOG | 4 +++- trunk/ripnews/news/article.rb | 16 ++++++++-------- trunk/ripnews/news/newsrc.rb | 1 - trunk/ripnews/ripnews.rb | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/trunk/ripnews/CHANGELOG b/trunk/ripnews/CHANGELOG index 23ceb80..e0948de 100644 --- a/trunk/ripnews/CHANGELOG +++ b/trunk/ripnews/CHANGELOG @@ -5,7 +5,9 @@ from 0.0.8 to 0.0.x - maxfilelength check - improved subject checking - linebuffered stdout - - always use push when adding stuff to an array this is way more + - always use push when adding stuff to an array, this is way more + efficient than += + - always use << when adding stuff to a string, this is way more efficient than += from 0.0.7 to 0.0.8 diff --git a/trunk/ripnews/news/article.rb b/trunk/ripnews/news/article.rb index 2b35d02..925965f 100644 --- a/trunk/ripnews/news/article.rb +++ b/trunk/ripnews/news/article.rb @@ -365,7 +365,7 @@ def get_group_body_rest(subj, file=nil) if file list.collect{|line| file.print "#{line}\n"} else - result += list + result.concat(list) end end end @@ -634,7 +634,7 @@ def _uudecode_array(data) next if line == nil next unless ((((line[0] - 32) & 077) + 2) / 3).to_i == (line.length/4).to_i - decode += line.unpack("u") + decode.concat(line.unpack("u")) end print "No \"end\" found!!!\n" @@ -654,7 +654,7 @@ def uudecode_group(subj, tempdir=nil) get_group_body_rest(subj, file) mode, filename, result = uudecode(file, outfile) else - body += get_group_body_rest(subj) + body.concat(get_group_body_rest(subj)) mode, filename, result = uudecode(body) end return mode, filename, result @@ -890,9 +890,9 @@ def _ydecode_array(data) special = 0 b = (b - 64) % 256 end - str += ((b - 42) % 256).chr + str << ((b - 42) % 256).chr } - decode += str + decode << str end print "${i}: no \"=yend\" found!!!\n" @@ -913,7 +913,7 @@ def ydecode_group(subj, tempdir=nil) get_group_body_rest(subj, file) mode, filename, result = ydecode(file, outfile) else - body += get_group_body_rest(subj) + body.concat(get_group_body_rest(subj)) mode, filename, result = ydecode(body) end return mode, filename, result @@ -1003,10 +1003,10 @@ def rechunk_runlist(runlist) if x =~ /(.*)-(.*)/ a = $1 while ($2.to_i - a.to_i) > 200 - result += "#{a}-#{a.to_i+199}," + result << "#{a}-#{a.to_i+199}," a = a.to_i + 200 end - result += "#{a}-#{$2}" + result << "#{a}-#{$2}" else x end diff --git a/trunk/ripnews/news/newsrc.rb b/trunk/ripnews/news/newsrc.rb index a225ac7..71c7c8a 100644 --- a/trunk/ripnews/news/newsrc.rb +++ b/trunk/ripnews/news/newsrc.rb @@ -68,7 +68,6 @@ def parse(line) "articles" => Set::IntSpan.new(articles)} @newsrc["group"][name] = group - #@newsrc["list"] += [ group ] @newsrc["list"].push(group) end diff --git a/trunk/ripnews/ripnews.rb b/trunk/ripnews/ripnews.rb index bc1448b..e310b61 100755 --- a/trunk/ripnews/ripnews.rb +++ b/trunk/ripnews/ripnews.rb @@ -109,7 +109,7 @@ def parse_config(default = {}) while i < lines.length line = lines[i] while line.sub!(/\s*\\$/, "") != nil - line += lines[i+1] + line << lines[i+1] i += 1 end line.sub!(/\s*$/, "") @@ -121,14 +121,14 @@ def parse_config(default = {}) if line =~ /(.*?)\s*\+=\s*(.*)/ if group == "" if default.has_key?($1) - default[$1] += $2 + default[$1] << $2 else default[$1] = $2 end else grouparr.collect{|g| if @config[g].has_key?($1) - @config[g][$1] += $2 + @config[g][$1] << $2 elsif default.has_key?($1) @config[g][$1] = default[$1] + $2 else