Project

General

Profile

Backport #5835

Please Backport r34202 and r34204 (rexml BaseParser uses instance_eval unnecessarily on listener add)

Added by headius (Charles Nutter) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-

Description

In add_listener in REXML::BaseParser, there's code to instance eval and replace the old "pull" method with a new one that calls all listeners. I assume this was done to avoid the cost of calling .each on the listeners when there's none registered, but when the list is empty this call is nearly a no-op anyway. The singletonizing effect of instance_eval and the redefinition of #pull, on the other hand, cause a cache flush throughout the system.

I have created a patch that removes the instance_eval, initializes the listeners array unconditionally, and does the event #each unconditionally. It passes all tests, and should perform better because it's not damaging the cache.

https://gist.github.com/1420383

This can be safely backported to any Ruby version and has no visible behavior change.


Files

backport_5835.patch (1.29 KB) backport_5835.patch ayumin (Ayumu AIZAWA), 01/04/2012 01:28 AM

History

Updated by ayumin (Ayumu AIZAWA) over 7 years ago

  • Subject changed from rexml BaseParser uses instance_eval unnecessarily on listener add to Please Backport r34202 (rexml BaseParser uses instance_eval unnecessarily on listener add)

Updated by kou (Kouhei Sutou) over 7 years ago

  • Subject changed from Please Backport r34202 (rexml BaseParser uses instance_eval unnecessarily on listener add) to Please Backport r34202 and r34204 (rexml BaseParser uses instance_eval unnecessarily on listener add)

Updated by ayumin (Ayumu AIZAWA) over 7 years ago

Updated by ayumin (Ayumu AIZAWA) over 7 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF