1 Feb 2004 01:09
Re: Save the flip/flop op!
Avi Bryant <avi <at> beta4.com>
2004-02-01 00:09:53 GMT
2004-02-01 00:09:53 GMT
ptkwt <at> aracnet.com (Phil Tomson) wrote in message news:<bvgv9u2mb1 <at> enews1.newsguy.com>...
> And just what would you replace that functionality with? It seems to me
> that it would take several lines of code to replace the following
> functionality:
>
> f.each_line {|l|
> if l=~/BEGIN/ .. l=~/END/
> #do something in this range of lines
> end
> }
What an odd operator! It took me a bit of toying around to figure out
exactly what it does (I didn't know what the scope of its state
variable was, but evidently it's the enclosing method).
Anyway, it seems to me you could pretty easily replace this with a
simple flipflop class:
ff = FlipFlop.new
f.each_line {|l|
ff.from(l=~/BEGIN/, l=~/END/) do
#do something in this range of lines
end
}
class FlipFlop
def initialize
<at> in_range = false
end
(Continue reading)
.
>
> Steve
Steve,
One thing you can do is run your code through the profiler (ruby -r
profile yourcode.rb) and show us the results. This could help us
identify a potential bottleneck in REXML and/or Ruby itself.
Regards,
Dan
RSS Feed