summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Lucas <evanlucas@me.com>2015-11-18 06:59:43 -0600
committerEvan Lucas <evanlucas@me.com>2015-12-21 10:54:01 -0600
commit50125e27b763aa49a93788c4605addf3c5966f44 (patch)
tree1666ca54b67181c4954736ccb346853a0fcdcf80
parent14f81a022dec3994a0a7fd034b91058d6bd2d975 (diff)
downloadandroid-node-v8-50125e27b763aa49a93788c4605addf3c5966f44.tar.gz
android-node-v8-50125e27b763aa49a93788c4605addf3c5966f44.tar.bz2
android-node-v8-50125e27b763aa49a93788c4605addf3c5966f44.zip
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>
-rw-r--r--lib/repl.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/repl.js b/lib/repl.js
index 8e81e61343..f80555dba4 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -568,7 +568,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 + ' ';
}
@@ -920,7 +921,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('');