perf: prefer absl::flat_hash_set over std::unordered_set (#46374)

* perf: use absl::flat_hash_set in SpellCheckClient::SpellCheckText()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* perf: use absl::flat_hash_set in MessagePort::DisentanglePorts()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-03-31 08:25:16 -05:00 committed by GitHub
parent 15d2a7dc4c
commit 65f9f08187
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -8,7 +8,6 @@
#include <memory>
#include <set>
#include <string_view>
#include <unordered_set>
#include <utility>
#include <vector>
@ -20,6 +19,7 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/function_template.h"
#include "shell/common/gin_helper/microtasks_scope.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
#include "third_party/blink/public/web/web_text_checking_completion.h"
#include "third_party/blink/public/web/web_text_checking_result.h"
#include "third_party/icu/source/common/unicode/uscript.h"
@ -182,9 +182,9 @@ void SpellCheckClient::SpellCheckText() {
void SpellCheckClient::OnSpellCheckDone(
const std::vector<std::u16string>& misspelled_words) {
const absl::flat_hash_set<std::u16string> misspelled{misspelled_words.begin(),
misspelled_words.end()};
std::vector<blink::WebTextCheckingResult> results;
std::unordered_set<std::u16string> misspelled(misspelled_words.begin(),
misspelled_words.end());
auto& word_list = pending_request_param_->wordlist();