MCPcopy Create free account
hub / github.com/SmingHub/Sming / compareTo

Method compareTo

Sming/Wiring/WString.cpp:536–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534/*********************************************/
535
536int String::compareTo(const char* cstr, size_t length) const
537{
538 auto len = this->length();
539 if(len == 0 || length == 0) {
540 return len - length;
541 }
542 auto buf = cbuffer();
543 assert(buf != nullptr && cstr != nullptr);
544 if(len == length) {
545 return memcmp(buf, cstr, len);
546 }
547 if(len < length) {
548 return memcmp(buf, cstr, len) ?: -1;
549 }
550 return memcmp(buf, cstr, length) ?: 1;
551}
552
553bool String::equals(const char* cstr) const
554{

Callers 1

compareMethod · 0.45

Calls 1

lengthMethod · 0.95

Tested by

no test coverage detected