Add check for theoretically impossible comparison, and drop nodenum comparison (#7165)

This commit is contained in:
Jonathan Bennett 2025-06-28 22:54:03 -05:00 committed by GitHub
parent 2bcf608654
commit b6a13f1114
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1696,6 +1696,8 @@ void NodeDB::sortMeshDB()
lastSort = millis();
std::sort(meshNodes->begin(), meshNodes->begin() + numMeshNodes,
[](const meshtastic_NodeInfoLite &a, const meshtastic_NodeInfoLite &b) {
if (a.num == myNodeInfo.my_node_num && b.num == myNodeInfo.my_node_num) // in theory impossible
return false;
if (a.num == myNodeInfo.my_node_num) {
return true;
}
@ -1706,9 +1708,7 @@ void NodeDB::sortMeshDB()
bool bFav = b.is_favorite;
if (aFav != bFav)
return aFav;
if (a.last_heard != b.last_heard)
return a.last_heard > b.last_heard;
return a.num > b.num;
return a.last_heard > b.last_heard;
});
}
}