Refactor BuildInfo so that it takes alphabetical order into account.
PiperOrigin-RevId: 476859483
Change-Id: Ied8cb1dbcc8cde6a4161140e5c6656154777386b
diff --git a/tools/cpp/build_info_entry_set.cc b/tools/cpp/build_info_entry_set.cc
index 3132b70..f7d0b47 100644
--- a/tools/cpp/build_info_entry_set.cc
+++ b/tools/cpp/build_info_entry_set.cc
@@ -15,6 +15,7 @@
#include "tools/cpp/build_info_entry_set.h"
#include <iostream>
+#include <map>
namespace bazel {
namespace tools {
@@ -42,17 +43,14 @@
return false;
}
-std::unordered_map<std::string, BuildInfoEntrySet::BuildInfoEntry>
+std::map<std::string, BuildInfoEntrySet::BuildInfoEntry>
BuildInfoEntrySet::TranslateKeys(
- const std::unordered_map<std::string, std::string>& key_translations,
+ const std::map<std::string, std::string>& translation_keys,
std::unordered_map<std::string, KeyDescription>& keys,
std::unordered_map<std::string, std::string>& values) {
- std::unordered_map<std::string, BuildInfoEntrySet::BuildInfoEntry>
- translated_keys =
- std::unordered_map<std::string, BuildInfoEntrySet::BuildInfoEntry>();
- for (const auto& i : key_translations) {
- std::string translation = i.first;
- std::string key = i.second;
+ std::map<std::string, BuildInfoEntrySet::BuildInfoEntry> translated_keys =
+ std::map<std::string, BuildInfoEntrySet::BuildInfoEntry>();
+ for (const auto& [translation, key] : translation_keys) {
std::string key_value;
if (GetKeyValue(key, keys, values, key_value) &&
keys.find(key) != keys.end()) {