MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / findNextBoundary

Method findNextBoundary

source/core/StarStringView.cpp:300–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300size_t StringView::findNextBoundary(size_t index, bool backwards) const {
301 //TODO: Make this faster.
302 size_t mySize = size();
303 starAssert(index <= mySize);
304 if (!backwards && (index == mySize))
305 return index;
306 if (backwards) {
307 if (index == 0)
308 return 0;
309 index--;
310 }
311 Char c = this->at(index);
312 while (!String::isSpace(c)) {
313 if (backwards && (index == 0))
314 return 0;
315 index += backwards ? -1 : 1;
316 if (index == mySize)
317 return mySize;
318 c = this->at(index);
319 }
320 while (String::isSpace(c)) {
321 if (backwards && (index == 0))
322 return 0;
323 index += backwards ? -1 : 1;
324 if (index == mySize)
325 return mySize;
326 c = this->at(index);
327 }
328 if (backwards && !(index == mySize))
329 return index + 1;
330 return index;
331}
332
333bool StringView::contains(StringView s, CaseSensitivity cs) const {
334 return find(s, 0, cs) != NPos;

Callers

nothing calls this directly

Calls 2

atMethod · 0.95
sizeFunction · 0.85

Tested by

no test coverage detected