MCPcopy Create free account
hub / github.com/apache/impala / StringCompare

Function StringCompare

be/src/runtime/string-value.inline.h:36–45  ·  view source on GitHub ↗

Compare two strings. Returns: < 0 if s1 < s2 0 if s1 == s2 > 0 if s1 > s2 - s1/n1: ptr/len for the first string - s2/n2: ptr/len for the second string - len: min(n1, n2) - this can be more cheaply passed in by the caller

Source from the content-addressed store, hash-verified

34/// - s2/n2: ptr/len for the second string
35/// - len: min(n1, n2) - this can be more cheaply passed in by the caller
36static inline int StringCompare(const char* s1, int n1, const char* s2, int n2, int len) {
37 // memcmp has undefined behavior when called on nullptr for either pointer
38 //
39 // GCC gives a warning about overflowing the size argument of memcmp, because
40 // it thinks 'len' can be negative. 'len' is never negative, so, this just uses
41 // len <= 0 and returns 0 for that case to avoid the warning.
42 const int result = (len <= 0) ? 0 : memcmp(s1, s2, len);
43 if (result != 0) return result;
44 return n1 - n2;
45}
46
47inline int StringValue::Compare(const StringValue& other) const {
48 SimpleString this_s = ToSimpleString();

Callers 7

EqMethod · 0.70
RunTestCaseFunction · 0.70
CompareMethod · 0.70
EqMethod · 0.70
CompareMethod · 0.70
WriteSlotMethod · 0.50
IrGenericIsNullStringFunction · 0.50

Calls

no outgoing calls

Tested by 1

RunTestCaseFunction · 0.56