Although StringRef::compare guarantees to return 0, 1, or -1, testing against 0 saves a single instruction in the implementation of < by replacing a cmp/sete with shr, at least when compiling with Clang. (GCC appears to figure out the idiom regardless.) It's also more obvious that the implementations are correct because the bodies match the operator names.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo