[debugger] optimize context's properties initialization, make 'list' a function,...
authorFedor Indutny <fedor.indutny@gmail.com>
Wed, 21 Sep 2011 10:08:31 +0000 (17:08 +0700)
committerRyan Dahl <ry@tinyclouds.org>
Wed, 21 Sep 2011 20:27:24 +0000 (13:27 -0700)
lib/_debugger.js

index be54c45..ef456c6 100644 (file)
@@ -737,13 +737,16 @@ function Interface() {
 
   function defineProperty(key, protoKey) {
     // Check arity
+    var fn = proto[protoKey].bind(self);
+
     if (proto[protoKey].length === 0) {
       Object.defineProperty(self.repl.context, key, {
-        get: proto[protoKey].bind(self),
-        enumerable: true
+        get: fn,
+        enumerable: true,
+        configurable: false
       });
     } else {
-      self.repl.context[key] = proto[protoKey].bind(self);
+      self.repl.context[key] = fn;
     }
   };
 
@@ -1021,12 +1024,13 @@ Interface.prototype.version = function() {
 };
 
 // List source code
-Interface.prototype.list = function() {
+Interface.prototype.list = function(delta) {
   if (!this.requireConnection()) return;
 
+  delta || (delta = 5);
+
   var self = this,
       client = this.client,
-      delta = arguments[0] || 5,
       from = client.currentSourceLine - delta + 1,
       to = client.currentSourceLine + delta + 1;