1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * @fileoverview Utilities for strings.
9 goog.provide('StringUtil');
14 StringUtil = function() {};
17 * Returns the length of the longest common prefix of two strings.
18 * @param {string} first The first string.
19 * @param {string} second The second string.
20 * @return {number} The length of the longest common prefix, which may be 0
21 * for an empty common prefix.
23 StringUtil.longestCommonPrefixLength = function(first, second) {
24 var limit = Math.min(first.length, second.length);
26 for (i = 0; i < limit; ++i) {
27 if (first.charAt(i) != second.charAt(i)) {