MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / splitWithoutEmptyParts

Method splitWithoutEmptyParts

Sources/Shared/Containers/StringView.cpp:57–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55 }
56
57 template<class T> Array<BasicStringView<T>> BasicStringView<T>::splitWithoutEmptyParts(const char delimiter) const {
58 Array<BasicStringView<T>> parts;
59 T* const end = this->end();
60 T* oldpos = _data;
61 while (oldpos < end) {
62 T* pos = static_cast<T*>(std::memchr(oldpos, delimiter, end - oldpos));
63 // Not sure why memchr can't just do this, it would make much more sense
64 if (!pos) pos = end;
65
66 if (pos != oldpos)
67 arrayAppend(parts, slice(oldpos, pos));
68
69 oldpos = pos + 1;
70 }
71
72 return parts;
73 }
74
75 namespace Implementation
76 {

Callers

nothing calls this directly

Calls 3

endMethod · 0.95
arrayAppendFunction · 0.85
sliceFunction · 0.85

Tested by

no test coverage detected