6fbb8bc806
Certain collators and subject strings may take this new fast path without calling into the (slow) ICU comparison functions. This CL can be roughly split into three topics: 1. The fast path check, precomputed and implemented as a whitelist on the current locale string. 2. The actual fast path, which checks subject string eligibility and performs L1 and L3 collation weight comparisons all in one pass. 3. Resuming from an aborted fast-path into the generic path. A longer overview is available at https://docs.google.com/document/d/1oyDwjYn2JyHsx2YnJJKhjX0WMNQXb8ao86-DRzqiYNg/edit?usp=sharing JetStream2/cdjs scores improve by roughly 40%. Bug: v8:12196 Change-Id: I5e1bbd731a36c361af9667f9104d6fa15c42e117 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3149463 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/main@{#77284}
37 lines
1.6 KiB
JavaScript
37 lines
1.6 KiB
JavaScript
// Copyright 2021 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Equal prefix.
|
|
assertTrue("asdf".localeCompare("asdf") == 0);
|
|
assertTrue("asd".localeCompare("asdf") < 0);
|
|
assertTrue("asdff".localeCompare("asdf") > 0);
|
|
|
|
// Chars differ.
|
|
assertTrue("asdf".localeCompare("asdq") < 0);
|
|
assertTrue("asdq".localeCompare("asdf") > 0);
|
|
|
|
// Interesting locales.
|
|
assertEquals('ö'.localeCompare('oe', 'de'), -1);
|
|
assertEquals('Ö'.localeCompare('oe', 'de'), -1);
|
|
assertEquals('ö'.localeCompare('o', 'de-u-co-phonebk'), 1);
|
|
assertEquals('ö'.localeCompare('p', 'de-u-co-phonebk'), -1);
|
|
assertEquals('Ö'.localeCompare('o', 'de-u-co-phonebk'), 1);
|
|
assertEquals('Ö'.localeCompare('p', 'de-u-co-phonebk'), -1);
|
|
assertEquals('ö'.localeCompare('o\u0308', 'de-u-co-phonebk'), 0);
|
|
assertEquals('ö'.localeCompare('O\u0308', 'de-u-co-phonebk'), -1);
|
|
assertEquals('Ö'.localeCompare('o\u0308', 'de-u-co-phonebk'), 1);
|
|
assertEquals('Ö'.localeCompare('O\u0308', 'de-u-co-phonebk'), 0);
|
|
|
|
assertEquals('ch'.localeCompare('ca', 'cs-CZ'), 1);
|
|
assertEquals('AA'.localeCompare('A-A', 'th'), 0);
|
|
|
|
// Attempt to hit different cases of the localeCompare fast path.
|
|
assertEquals('aAaaaö'.localeCompare('aaaaaö', 'en-US'), 1);
|
|
assertEquals('aaaaaöA'.localeCompare('aaaaaöa', 'en-US'), 1);
|
|
assertEquals('ab\u0308'.localeCompare('aa\u0308', 'en-US'), 1);
|
|
assertEquals('aA'.localeCompare('aaa', 'en-US'), -1);
|
|
assertEquals('aa'.localeCompare('aAa', 'en-US'), -1);
|
|
assertEquals('aA'.localeCompare('aa', 'en-US'), 1);
|
|
assertEquals('aa'.localeCompare('aA', 'en-US'), -1);
|