Make idl_parser deterministic (#6976)

* Make idl_parser deterministic

Some golden tests even exercise this [logic](df2df21ec1/tests/prototest/test.golden (L8)). Let's make the parser fully stable not depending on the implementation of std::sort

* Retry the ci
This commit is contained in:
Danila Kutenin
2021-12-09 21:07:29 +00:00
committed by GitHub
parent d0cede9c90
commit 11749095a1

View File

@@ -2152,10 +2152,16 @@ void EnumDef::SortByValue() {
auto &v = vals.vec;
if (IsUInt64())
std::sort(v.begin(), v.end(), [](const EnumVal *e1, const EnumVal *e2) {
if (e1->GetAsUInt64() == e2->GetAsUInt64()) {
return e1->name < e2->name;
}
return e1->GetAsUInt64() < e2->GetAsUInt64();
});
else
std::sort(v.begin(), v.end(), [](const EnumVal *e1, const EnumVal *e2) {
if (e1->GetAsInt64() == e2->GetAsInt64()) {
return e1->name < e2->name;
}
return e1->GetAsInt64() < e2->GetAsInt64();
});
}