0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

[debugger] optimize context's properties initialization, make 'list' a function, not a getter

This commit is contained in:
Fedor Indutny 2011-09-21 17:08:31 +07:00 committed by Ryan Dahl
parent 3148f1400e
commit 79fd1f7f0b

View 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;