From f9c680a9bad9f127e1336c85aa9564ba2d1db159 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Wed, 21 Oct 2009 17:58:09 +0200 Subject: [PATCH] More nitpicking. --- src/lang/string.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lang/string.js b/src/lang/string.js index c22885e..26c3cf2 100644 --- a/src/lang/string.js +++ b/src/lang/string.js @@ -429,8 +429,8 @@ Object.extend(String.prototype, (function() { * Checks if the string starts with `substring`. **/ function startsWith(pattern) { - // Using `lastIndexOf` instead of `indexOf` because execution time doesn't - // depend on string length. + // We use `lastIndexOf` instead of `indexOf` to avoid tying execution + // time to string length when string doesn't start with pattern. return this.lastIndexOf(pattern, 0) === 0; } @@ -441,8 +441,8 @@ Object.extend(String.prototype, (function() { **/ function endsWith(pattern) { var d = this.length - pattern.length; - // Using `indexOf` instead of `lastIndexOf` because execution time doesn't - // depend on string length. + // We use `indexOf` instead of `lastIndexOf` to avoid tying execution + // time to string length when string doesn't end with pattern. return d >= 0 && this.indexOf(pattern, d) === d; }