From 8e33d670ab686bb7024fcb3efa677e7ca28fc8c6 Mon Sep 17 00:00:00 2001 From: Rafael Weinstein Date: Thu, 5 Sep 2013 14:41:02 -0700 Subject: [PATCH] optimize unbind R=arv BUG= Review URL: https://codereview.appspot.com/13527046 --- src/NodeBind.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/NodeBind.js b/src/NodeBind.js index 84fba48..4b96484 100644 --- a/src/NodeBind.js +++ b/src/NodeBind.js @@ -50,11 +50,14 @@ }; Node.prototype.unbind = function(name) { - this.bindings = this.bindings || {}; + if (!this.bindings) + this.bindings = {}; + if (!this.bindings[name]) + return; var binding = this.bindings[name]; if (binding && typeof binding.close === 'function') binding.close(); - delete this.bindings[name]; + this.bindings[name] = undefined; }; Node.prototype.unbindAll = function() {