diff --git a/CHANGELOG b/CHANGELOG index f5df87f..8934083 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +* String#startsWith, String#endsWith performance optimization (Yaffle, Tobie Langel, kangax) + +* Rewrite String#camelize using String#replace with a replacement function (Phred, John-David Dalton, Samuel Lebeau, kangax) + *1.6.1* (August 24, 2009) * Avoid triggering a warning when Java is disabled in IE8. [#668 state:resolved] (orv, kangax, Andrew Dupont, Tobie Langel) diff --git a/src/lang/string.js b/src/lang/string.js index 16935a7..3c7f23f 100644 --- a/src/lang/string.js +++ b/src/lang/string.js @@ -429,7 +429,7 @@ Object.extend(String.prototype, (function() { * Checks if the string starts with `substring`. **/ function startsWith(pattern) { - return this.indexOf(pattern) === 0; + return !this.lastIndexOf(pattern,0); } /** @@ -439,7 +439,7 @@ Object.extend(String.prototype, (function() { **/ function endsWith(pattern) { var d = this.length - pattern.length; - return d >= 0 && this.lastIndexOf(pattern) === d; + return d >= 0 && this.indexOf(pattern,d) === d; } /**