mirror of
https://github.com/google/flatbuffers.git
synced 2026-08-03 20:11:55 +00:00
Make idl_parser deterministic (#6976)
* Make idl_parser deterministic Some golden tests even exercise this [logic](https://github.com/google/flatbuffers/blob/df2df21ec1be2468106fed10c1533eacc1cf0d2e/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:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user