diff options
author | ayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-03 15:05:20 +0000 |
---|---|---|
committer | ayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-03 15:05:20 +0000 |
commit | 5eac56441ca1bfe38fdf3ffc1893d9cbc431529f (patch) | |
tree | 4642b4cdd15cad42989ab381924265346d07fb76 /lib/rexml/parsers/baseparser.rb | |
parent | c5335bd18fdca8e02662ae2b768e30501624b40a (diff) | |
download | ruby-5eac56441ca1bfe38fdf3ffc1893d9cbc431529f.tar.gz |
* 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
Diffstat (limited to 'lib/rexml/parsers/baseparser.rb')
-rw-r--r-- | lib/rexml/parsers/baseparser.rb | 22 |
1 files changed, 9 insertions, 13 deletions
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 ] |