From 5eac56441ca1bfe38fdf3ffc1893d9cbc431529f Mon Sep 17 00:00:00 2001 From: ayumin Date: Tue, 3 Jan 2012 15:05:20 +0000 Subject: * lib/rexml/parsers/baseparser.rb: rexml BaseParser uses instance_eval unnecessarily on listener add. patch from Charles Nutter. [Bug #5696] [ruby-core:41437] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rexml/parsers/baseparser.rb | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'lib/rexml') diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb index 6cddf6fc2c..a992f4c710 100644 --- a/lib/rexml/parsers/baseparser.rb +++ b/lib/rexml/parsers/baseparser.rb @@ -114,22 +114,10 @@ module REXML def initialize( source ) self.stream = source + @listeners = [] end def add_listener( listener ) - if !defined?(@listeners) or !@listeners - @listeners = [] - instance_eval <<-EOL - alias :_old_pull :pull - def pull - event = _old_pull - @listeners.each do |listener| - listener.receive event - end - event - end - EOL - end @listeners << listener end @@ -192,6 +180,14 @@ module REXML # Returns the next event. This is a +PullEvent+ object. def pull + _pull_inner.tap do |event| + @listeners.each do |listener| + listener.receive event + end + end + end + + def _pull_inner if @closed x, @closed = @closed, nil return [ :end_element, x ] -- cgit v1.2.3