Improve lang.stringRepeat function perfomance
This commit is contained in:
parent
153562054d
commit
d12e5c4548
1 changed files with 10 additions and 1 deletions
|
|
@ -36,7 +36,16 @@ exports.stringReverse = function(string) {
|
|||
};
|
||||
|
||||
exports.stringRepeat = function (string, count) {
|
||||
return new Array(count + 1).join(string);
|
||||
var result = '';
|
||||
while (count)
|
||||
{
|
||||
if (count & 1)
|
||||
result += string;
|
||||
|
||||
if (count >>= 1)
|
||||
string += string;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var trimBeginRegexp = /^\s\s*/;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue