Skip to content

Commit 4a044af

Browse files
sunnylostjamesdaily
authored andcommitted
refactor(angular.js): improve trim performance
According to Flagrant Badassery's blog http://blog.stevenlevithan.com/archives/faster-trim-javascript and this comparison http://jsperf.com/trim-function, this trim method is faster. Closes angular#4406
1 parent 7d7236b commit 4a044af

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Angular.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ var trim = (function() {
544544
// TODO: we should move this into IE/ES5 polyfill
545545
if (!String.prototype.trim) {
546546
return function(value) {
547-
return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value;
547+
return isString(value) ? value.replace(/^\s\s*/, '').replace(/\s\s*$/, '') : value;
548548
};
549549
}
550550
return function(value) {

0 commit comments

Comments
 (0)