Simplify operator<

This commit is contained in:
Daniel Smith 2020-02-07 14:49:52 -05:00
parent 7f490de27c
commit 6ede94f2b6
1 changed files with 2 additions and 12 deletions

View File

@ -116,18 +116,8 @@ bool operator<(const KeyInfo& lhs, const KeyInfo& rhs) {
int c = memcmp(lhs.key.begin(), rhs.key.begin(), i);
if (c != 0) return c < 0;
// SOMEDAY: This is probably not very fast. Slows D.Sort by ~20% relative to previous (incorrect) version.
bool lDone, rDone;
int lc, rc;
while (true) {
lDone = getCharacter(lhs, i, lc);
rDone = getCharacter(rhs, i, rc);
if (lDone && rDone) return false; // equality
if (lc < rc) return true;
if (lc > rc) return false;
i++;
}
// Always sort shorter keys before longer keys.
return lhs.key.size() < rhs.key.size();
}
bool operator==(const KeyInfo& lhs, const KeyInfo& rhs) {