diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/rexml/parsers/baseparser.rb | 22 |
2 files changed, 15 insertions, 13 deletions
@@ -1,3 +1,9 @@ +Tue Jan 03 23:57:37 2012 Ayumu AIZAWA <ayumu.aizawa@gmail.com> + + * lib/rexml/parsers/baseparser.rb: rexml BaseParser uses + instance_eval unnecessarily on listener add. + patch from Charles Nutter. [Bug #5696] [ruby-core:41437] + Tue Jan 03 20:44:13 2012 Ayumu AIZAWA <ayumu.aizawa@gmail.com> * README: add comment for Git user. patch from Arun Agrawal. 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 ] |