MCPcopy Create free account
hub / github.com/FastLED/FastLED / string_compare

Function string_compare

src/fl/stl/string.cpp.hpp:211–218  ·  view source on GitHub ↗

Length-aware lexicographic compare. Doesn't rely on strcmp's NUL-termination, so view-backed strings (`setView`) and any future embedded-NUL content compare correctly. Returns the same sign convention as memcmp / strcmp.

Source from the content-addressed store, hash-verified

209// future embedded-NUL content compare correctly. Returns the same
210// sign convention as memcmp / strcmp.
211static inline int string_compare(const string& a, const string& b) FL_NOEXCEPT {
212 fl::size n = (a.size() < b.size()) ? a.size() : b.size();
213 int r = fl::memcmp(a.c_str(), b.c_str(), n);
214 if (r != 0) return r;
215 if (a.size() < b.size()) return -1;
216 if (a.size() > b.size()) return 1;
217 return 0;
218}
219
220bool string::operator>(const string& other) const FL_NOEXCEPT {
221 return string_compare(*this, other) > 0;

Callers 4

operator>Method · 0.85
operator>=Method · 0.85
operator<Method · 0.85
operator<=Method · 0.85

Calls 3

memcmpFunction · 0.85
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected