Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9855fab

Browse filesBrowse files
evanlucasMyles Borins
authored andcommitted
repl: use String#repeat instead of Array#join
String#repeat is quite a bit faster than new Array().join(). PR-URL: #3900 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
1 parent 9baa561 commit 9855fab
Copy full SHA for 9855fab

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ REPLServer.prototype.displayPrompt = function(preserveCursor) {
554554
var prompt = this._initialPrompt;
555555
if (this.bufferedCommand.length) {
556556
prompt = '...';
557-
var levelInd = new Array(this.lines.level.length).join('..');
557+
const len = this.lines.level.length ? this.lines.level.length - 1 : 0;
558+
const levelInd = '..'.repeat(len);
558559
prompt += levelInd + ' ';
559560
}
560561

@@ -906,7 +907,8 @@ REPLServer.prototype.memory = function memory(cmd) {
906907
// save the line so I can do magic later
907908
if (cmd) {
908909
// TODO should I tab the level?
909-
self.lines.push(new Array(self.lines.level.length).join(' ') + cmd);
910+
const len = self.lines.level.length ? self.lines.level.length - 1 : 0;
911+
self.lines.push(' '.repeat(len) + cmd);
910912
} else {
911913
// I don't want to not change the format too much...
912914
self.lines.push('');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.