-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[modularize] Avoid repeated hash lookups (NFC) #109508
Merged
kazutakahirata
merged 3 commits into
llvm:main
from
kazutakahirata:cleanup_001_repeated_hash_Modularize
Sep 21, 2024
Merged
[modularize] Avoid repeated hash lookups (NFC) #109508
kazutakahirata
merged 3 commits into
llvm:main
from
kazutakahirata:cleanup_001_repeated_hash_Modularize
Sep 21, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
@llvm/pr-subscribers-clang-tools-extra Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/109508.diff 1 Files Affected:
diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp
index f3e7dfc20b027d..92e4792526d6f3 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -508,13 +508,11 @@ class EntityMap : public std::map<std::string, SmallVector<Entry, 2>> {
// Sort contents.
llvm::sort(H->second);
- // Check whether we've seen this header before.
- auto KnownH = AllHeaderContents.find(H->first);
- if (KnownH == AllHeaderContents.end()) {
- // We haven't seen this header before; record its contents.
- AllHeaderContents.insert(*H);
+ // Record this header and its contents if we haven't seen it before.
+ auto [KnownH, Inserted] =
+ AllHeaderContents.try_emplace(H->first, H->second);
+ if (Inserted)
continue;
- }
// If the header contents are the same, we're done.
if (H->second == KnownH->second)
|
nikic
reviewed
Sep 21, 2024
Co-authored-by: Nikita Popov <github@npopov.com>
|
Revised the patch. Please take a look. Thanks! |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
nikic
approved these changes
Sep 21, 2024
augusto2112
pushed a commit
to augusto2112/llvm-project
that referenced
this pull request
Sep 26, 2024
Co-authored-by: Nikita Popov <github@npopov.com>
xgupta
pushed a commit
to xgupta/llvm-project
that referenced
this pull request
Oct 4, 2024
Co-authored-by: Nikita Popov <github@npopov.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.