mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
repl: use String#repeat instead of Array#join
String#repeat is quite a bit faster than new Array().join(). PR-URL: https://github.com/nodejs/node/pull/3900 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
This commit is contained in:
1 parent
9baa5618f5
commit
9855fab05f
1 file changed
+4
-2
+4
-2
@@ -554,7 +554,8 @@ REPLServer.prototype.displayPrompt = function(preserveCursor) {
|
||||
var prompt = this._initialPrompt;
|
||||
if (this.bufferedCommand.length) {
|
||||
prompt = '...';
|
||||
var levelInd = new Array(this.lines.level.length).join('..');
|
||||
const len = this.lines.level.length ? this.lines.level.length - 1 : 0;
|
||||
const levelInd = '..'.repeat(len);
|
||||
prompt += levelInd + ' ';
|
||||
}
|
||||
|
||||
@@ -906,7 +907,8 @@ REPLServer.prototype.memory = function memory(cmd) {
|
||||
// save the line so I can do magic later
|
||||
if (cmd) {
|
||||
// TODO should I tab the level?
|
||||
self.lines.push(new Array(self.lines.level.length).join(' ') + cmd);
|
||||
const len = self.lines.level.length ? self.lines.level.length - 1 : 0;
|
||||
self.lines.push(' '.repeat(len) + cmd);
|
||||
} else {
|
||||
// I don't want to not change the format too much...
|
||||
self.lines.push('');
|
||||
|
||||
Reference in new issue
Block a user