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

Function GenericFind

be/src/gutil/strings/split.cc:43–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41// StringPiece::find_first_of().
42template <typename FindPolicy>
43StringPiece GenericFind(
44 StringPiece text,
45 StringPiece delimiter,
46 FindPolicy find_policy) {
47 if (delimiter.empty() && text.length() > 0) {
48 // Special case for empty string delimiters: always return a zero-length
49 // StringPiece referring to the item at position 1.
50 return StringPiece(text.begin() + 1, 0);
51 }
52 int found_pos = StringPiece::npos;
53 StringPiece found(text.end(), 0); // By default, not found
54 found_pos = find_policy.Find(text, delimiter);
55 if (found_pos != StringPiece::npos) {
56 found.set(text.data() + found_pos, find_policy.Length(delimiter));
57 }
58 return found;
59}
60
61// Finds using StringPiece::find(), therefore the length of the found delimiter
62// is delimiter.length().

Callers 1

FindMethod · 0.85

Calls 9

StringPieceClass · 0.70
emptyMethod · 0.45
lengthMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
FindMethod · 0.45
setMethod · 0.45
dataMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected