Skip to content

Commit 68004d0

Browse files
authored
Use an std::map for Configuration::Lock entries too (#624)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent ecdda50 commit 68004d0

2 files changed

Lines changed: 10 additions & 61 deletions

File tree

src/configuration/include/sourcemeta/blaze/configuration.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ struct SOURCEMETA_BLAZE_CONFIGURATION_EXPORT Configuration {
8383
};
8484
};
8585

86-
using const_iterator = std::unordered_map<sourcemeta::core::JSON::String,
87-
Entry>::const_iterator;
86+
using const_iterator =
87+
std::map<sourcemeta::core::JSON::String, Entry>::const_iterator;
8888

8989
auto
9090
emplace(const sourcemeta::core::JSON::String &uri,
@@ -109,7 +109,8 @@ struct SOURCEMETA_BLAZE_CONFIGURATION_EXPORT Configuration {
109109
auto to_json() const -> sourcemeta::core::JSON;
110110

111111
private:
112-
std::unordered_map<sourcemeta::core::JSON::String, Entry> entries_;
112+
// Ordered to guarantee deterministic iteration
113+
std::map<sourcemeta::core::JSON::String, Entry> entries_;
113114
};
114115

115116
/// An event emitted during dependency fetching

test/configuration/configuration_fetch_frozen_test.cc

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,64 +1289,12 @@ TEST(Configuration_fetch_frozen, multiple_orphaned_entries) {
12891289
true);
12901290

12911291
EXPECT_EQ(events.size(), 3);
1292-
if (events[0].uri == "https://example.com/orphaned1.json") {
1293-
EXPECT_FETCH_EVENT(events[0], Orphaned,
1294-
"https://example.com/orphaned1.json", "orphaned1.json",
1295-
0, 0, "");
1296-
if (events[1].uri == "https://example.com/orphaned2.json") {
1297-
EXPECT_FETCH_EVENT(events[1], Orphaned,
1298-
"https://example.com/orphaned2.json", "orphaned2.json",
1299-
0, 0, "");
1300-
EXPECT_FETCH_EVENT(events[2], Orphaned,
1301-
"https://example.com/orphaned3.json", "orphaned3.json",
1302-
0, 0, "");
1303-
} else {
1304-
EXPECT_FETCH_EVENT(events[1], Orphaned,
1305-
"https://example.com/orphaned3.json", "orphaned3.json",
1306-
0, 0, "");
1307-
EXPECT_FETCH_EVENT(events[2], Orphaned,
1308-
"https://example.com/orphaned2.json", "orphaned2.json",
1309-
0, 0, "");
1310-
}
1311-
} else if (events[0].uri == "https://example.com/orphaned2.json") {
1312-
EXPECT_FETCH_EVENT(events[0], Orphaned,
1313-
"https://example.com/orphaned2.json", "orphaned2.json",
1314-
0, 0, "");
1315-
if (events[1].uri == "https://example.com/orphaned1.json") {
1316-
EXPECT_FETCH_EVENT(events[1], Orphaned,
1317-
"https://example.com/orphaned1.json", "orphaned1.json",
1318-
0, 0, "");
1319-
EXPECT_FETCH_EVENT(events[2], Orphaned,
1320-
"https://example.com/orphaned3.json", "orphaned3.json",
1321-
0, 0, "");
1322-
} else {
1323-
EXPECT_FETCH_EVENT(events[1], Orphaned,
1324-
"https://example.com/orphaned3.json", "orphaned3.json",
1325-
0, 0, "");
1326-
EXPECT_FETCH_EVENT(events[2], Orphaned,
1327-
"https://example.com/orphaned1.json", "orphaned1.json",
1328-
0, 0, "");
1329-
}
1330-
} else {
1331-
EXPECT_FETCH_EVENT(events[0], Orphaned,
1332-
"https://example.com/orphaned3.json", "orphaned3.json",
1333-
0, 0, "");
1334-
if (events[1].uri == "https://example.com/orphaned1.json") {
1335-
EXPECT_FETCH_EVENT(events[1], Orphaned,
1336-
"https://example.com/orphaned1.json", "orphaned1.json",
1337-
0, 0, "");
1338-
EXPECT_FETCH_EVENT(events[2], Orphaned,
1339-
"https://example.com/orphaned2.json", "orphaned2.json",
1340-
0, 0, "");
1341-
} else {
1342-
EXPECT_FETCH_EVENT(events[1], Orphaned,
1343-
"https://example.com/orphaned2.json", "orphaned2.json",
1344-
0, 0, "");
1345-
EXPECT_FETCH_EVENT(events[2], Orphaned,
1346-
"https://example.com/orphaned1.json", "orphaned1.json",
1347-
0, 0, "");
1348-
}
1349-
}
1292+
EXPECT_FETCH_EVENT(events[0], Orphaned, "https://example.com/orphaned1.json",
1293+
"orphaned1.json", 0, 0, "");
1294+
EXPECT_FETCH_EVENT(events[1], Orphaned, "https://example.com/orphaned2.json",
1295+
"orphaned2.json", 0, 0, "");
1296+
EXPECT_FETCH_EVENT(events[2], Orphaned, "https://example.com/orphaned3.json",
1297+
"orphaned3.json", 0, 0, "");
13501298
}
13511299

13521300
TEST(Configuration_fetch_frozen, resolver_returns_nullopt_during_bundle) {

0 commit comments

Comments
 (0)