Don't use substring() for a simple prefix match
The language code match in SVGTests::isValid() uses String::substring() to limit the match to the primary language subtag. In the case where the defaultLanguage() only contains the/a primary language subtag, this will not require a copy, but otherwise it would. Using startsWith() and a length-check guarantees that no copies will be made. (A valid primary language subtag is always 2 letter long, so checking only for length == 2 should be enough, although previously the code could theoretically match a 1 letter, or even a zero-length tag.) Review-Url: https://codereview.chromium.org/2284273002 Cr-Commit-Position: refs/heads/master@{#415255}
Showing
Please register or sign in to comment