Skip to content

Commit

Permalink
Improve events performance in some cases by 20x.
Browse files Browse the repository at this point in the history
Things like [Chaplin](http://chaplinjs.org) are using advanced memory management heavily. This includes unbinding of all events too.

Events are getting unbound all the time. When other objects may still try to trigger events, this will increase performance by 20x.

Initially taken from [my Backbone optional-dependencies fork](http://exosjs.com).

Proof of 20x speed: http://jsperf.com/exoskeleton-events-vs-backbone-events
  • Loading branch information
paulmillr committed Nov 7, 2013
1 parent ab5d2eb commit 1a2d3f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
var retain, ev, events, names, i, l, j, k;
if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
if (!name && !callback && !context) {
this._events = {};
this._events = void 0;
return this;
}
names = name ? [name] : _.keys(this._events);
Expand Down

0 comments on commit 1a2d3f2

Please sign in to comment.