mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
c5335bd18f
commit
5eac56441c
2 changed files with 15 additions and 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>
|
Tue Jan 03 20:44:13 2012 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
|
||||||
|
|
||||||
* README: add comment for Git user. patch from Arun Agrawal.
|
* README: add comment for Git user. patch from Arun Agrawal.
|
||||||
|
|
|
@ -114,22 +114,10 @@ module REXML
|
||||||
|
|
||||||
def initialize( source )
|
def initialize( source )
|
||||||
self.stream = source
|
self.stream = source
|
||||||
|
@listeners = []
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_listener( listener )
|
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
|
@listeners << listener
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -192,6 +180,14 @@ module REXML
|
||||||
|
|
||||||
# Returns the next event. This is a +PullEvent+ object.
|
# Returns the next event. This is a +PullEvent+ object.
|
||||||
def pull
|
def pull
|
||||||
|
_pull_inner.tap do |event|
|
||||||
|
@listeners.each do |listener|
|
||||||
|
listener.receive event
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def _pull_inner
|
||||||
if @closed
|
if @closed
|
||||||
x, @closed = @closed, nil
|
x, @closed = @closed, nil
|
||||||
return [ :end_element, x ]
|
return [ :end_element, x ]
|
||||||
|
|
Loading…
Add table
Reference in a new issue