mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 04:21:13 +00:00
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:
@@ -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