Skip to content

Commit

Permalink
Merge branch 'master' of github.com:andrewplummer/Sugar
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewplummer committed Oct 4, 2012
2 parents 7d4d5b2 + b187958 commit 15f5b09
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v1.3.6
======

### API Changes ###

- Faster String#repeat (Issue #214 - Thanks to @termi!).

v1.3.5
======

Expand Down
17 changes: 10 additions & 7 deletions lib/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,17 +761,21 @@
*
* 'jumpy'.repeat(2) -> 'jumpyjumpy'
* 'a'.repeat(5) -> 'aaaaa'
* 'a'.repeat(0) -> ''
*
***/
'repeat': function(num) {
var str = '', i = 0;
if(isNumber(num) && num > 0) {
while(i < num) {
str += this;
i++;
var result = '', str = this;
if(!isNumber(num) || num < 1) return '';
while (num) {
if (num & 1) {
result += str;
}
if (num >>= 1) {
str += str;
}
}
return str;
return result;
},

/***
Expand Down Expand Up @@ -859,7 +863,6 @@
});
return context;
}

});


Expand Down

0 comments on commit 15f5b09

Please sign in to comment.