From 76edc4f91400a608862e89ff7c98f1180b92eeda Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Mon, 26 Oct 2009 16:47:09 -0700 Subject: [PATCH] Use Array(n).join(ch) trick for strings of identical chars --- AppKit/CPTextField.j | 9 +-------- Objective-J/utilities.js | 5 +---- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 7994ab75f..ebf0815c9 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -951,14 +951,7 @@ var secureStringForString = function(aString) // This is true for when aString === "" and null/undefined. if (!aString) return ""; - - var secureString = "", - length = aString.length; - - while (length--) - secureString += CPSecureTextFieldCharacter; - - return secureString; + return Array(aString.length).join(CPSecureTextFieldCharacter); } diff --git a/Objective-J/utilities.js b/Objective-J/utilities.js index ac2e74386..617eb9cbe 100644 --- a/Objective-J/utilities.js +++ b/Objective-J/utilities.js @@ -168,10 +168,7 @@ var _sprintf_justify = function(sign, prefix, string, suffix, width, leftJustify var _sprintf_pad = function(n, ch) { - var result = ""; - for (var i = 0; i < n; i++) - result += ch; - return result; + return Array(Math.max(0,n)).join(ch); } // Base64 encoding and decoding