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

Function SplitStringToIteratorUsing

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

Source from the content-addressed store, hash-verified

379// ----------------------------------------------------------------------
380template <typename StringType, typename ITR>
381static inline
382void SplitStringToIteratorUsing(const StringType& full,
383 const char* delim,
384 ITR& result) {
385 // Optimize the common case where delim is a single character.
386 if (delim[0] != '\0' && delim[1] == '\0') {
387 char c = delim[0];
388 const char* p = full.data();
389 const char* end = p + full.size();
390 while (p != end) {
391 if (*p == c) {
392 ++p;
393 } else {
394 const char* start = p;
395 while (++p != end && *p != c) {
396 // Skip to the next occurence of the delimiter.
397 }
398 *result++ = StringType(start, p - start);
399 }
400 }
401 return;
402 }
403
404 string::size_type begin_index, end_index;
405 begin_index = full.find_first_not_of(delim);
406 while (begin_index != string::npos) {
407 end_index = full.find_first_of(delim, begin_index);
408 if (end_index == string::npos) {
409 *result++ = full.substr(begin_index);
410 return;
411 }
412 *result++ = full.substr(begin_index, (end_index - begin_index));
413 begin_index = full.find_first_not_of(delim, end_index);
414 }
415}
416
417void SplitStringUsing(const string& full,
418 const char* delim,

Callers 1

SplitStringUsingFunction · 0.85

Calls 5

find_first_not_ofMethod · 0.80
substrMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
find_first_ofMethod · 0.45

Tested by

no test coverage detected