Commit a7c31efa authored by manuk's avatar manuk Committed by Commit Bot

[chrome:omnibox] Limit matches' texts for filtering.

For matches with long text, the regex filtering algorithm's performance becomes
problematic. For matches of about 350 characters, occasional lag becomes
noticeable as you type the filter text. For matches of about 500 characters, the
page approaches unusable when trying to filter.

When the match text being filtered is longer than 200 characters, we truncate it
to 100 characters and `console.warn` a message.

Bug: 891303
Change-Id: I79d9ce5eb17b479ddb0584aa0ac2e461938e8dac
Reviewed-on: https://chromium-review.googlesource.com/c/1372308
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615665}
parent 93b08b15
......@@ -724,6 +724,12 @@ cr.define('omnibox_output', function() {
* @return {!Array<string>}
*/
static textToWords_(text) {
const MAX_TEXT_LENGTH = 200;
if (text.length > MAX_TEXT_LENGTH) {
text = text.slice(0, MAX_TEXT_LENGTH);
console.warn(`text to be filtered too long, truncatd; max length: ${
MAX_TEXT_LENGTH}, truncated text: ${text}`);
}
return text.match(/[a-z]+|[A-Z][a-z]*|\d+|./g) || [];
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment