diff options
author | Abseil Team <absl-team@google.com> | 2023-08-14 09:27:07 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-08-14 09:28:32 -0700 |
commit | 2890217b725a20a8b785b041bc7198fa2ec74870 (patch) | |
tree | db96326dcb82530d5ba2848f69e4aa28f483d6ef | |
parent | 861e53c8f075c8c4d67bd4c82217c57239fc97cf (diff) |
Speed up kTotalMorePrecise mode of Cord::EstimatedMemoryUsage() by about 25% by avoiding a redundant map lookup.
PiperOrigin-RevId: 556816759
Change-Id: I971e428bf12d91720df72a91cc0bdf0513b0c270
-rw-r--r-- | absl/strings/cord_analysis.cc | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/absl/strings/cord_analysis.cc b/absl/strings/cord_analysis.cc index fa1a0cc8..e3824281 100644 --- a/absl/strings/cord_analysis.cc +++ b/absl/strings/cord_analysis.cc @@ -67,8 +67,7 @@ struct RawUsage<Mode::kTotalMorePrecise> { std::unordered_set<const CordRep*> counted; void Add(size_t size, CordRepRef<Mode::kTotalMorePrecise> repref) { - if (counted.find(repref.rep) == counted.end()) { - counted.insert(repref.rep); + if (counted.insert(repref.rep).second) { total += size; } } |