Ticket #2880 (closed feature: fixed)

Opened 3 years ago

Last modified 3 years ago

handleBrowserEvent: don't compute mouseposition if it's not needed

Reported by: fredj Owned by: tschaub
Priority: minor Milestone: 2.11 Release
Component: Events Version:
Keywords: Cc:
State: Complete

Description

OpenLayers.Events.handleBrowserEvent compute the mouse position if includeXY is true but don't check if a listener is registered on the event type.

Attachments

2880.0.patch Download (0.6 KB) - added by fredj 3 years ago.
2880.1.patch Download (0.7 KB) - added by erilem 3 years ago.

Change History

Changed 3 years ago by fredj

Changed 3 years ago by erilem

addEventType initializes the type's listeners array to [], so I think we should do

var listeners = this.listeners[evt.type];
if(listeners && listeners.length > 0) {
    if (this.includeXY) {
        evt.xy = this.getMousePosition(evt);
    }
    this.triggerEvent(evt.type, evt);
}

just like what triggerEvent itself does.

Changed 3 years ago by erilem

Changed 3 years ago by erilem

  • state set to Commit

2880.1.patch Download

See the following FireBug profile results. Experiments involve panning the map using tilecache.html in full page.

Without patch
--------------
positionImage() 156 16.38%
toFloat() 12612	12.75%
triggerEvent() 3164 6.35%
centerLayerContainer() 211 5.58%
initialize() 2590 4.29%
handleBrowserEvent() 2234 3.54%
getMousePosition() 1120 3.11%

With patch
----------
positionImage()	150 16.61%
toFloat() 12406	12.46%
triggerEvent() 1874 5.67%
centerLayerContainer() 197 5.38%
initialize() 2532 4.58%
getMousePosition() 988 3.52%

With the patch, triggerEvent and getMousePosition are significantly less called.

Except Request.html (#2913) and Popup.html (#2919), all tests pass in FF3. The failing tests are unrelated to this patch, they fail even when this patch isn't applied.

fredj, please commit if you agree with 2880.1.patch Download.

Changed 3 years ago by fredj

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed
Note: See TracTickets for help on using tickets.