MCPcopy Create free account
hub / github.com/DFHack/dfhack / prefix_matches

Function prefix_matches

library/MiscUtils.cpp:449–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447}
448
449bool prefix_matches(const std::string &prefix, const std::string &key, std::string *tail)
450{
451 size_t ksize = key.size();
452 size_t psize = prefix.size();
453 if (ksize < psize || memcmp(prefix.data(), key.data(), psize) != 0)
454 return false;
455 if (tail)
456 tail->clear();
457 if (ksize == psize)
458 return true;
459 if (psize == 0 || prefix[psize-1] == '/')
460 {
461 if (tail) *tail = key.substr(psize);
462 return true;
463 }
464 if (key[psize] == '/')
465 {
466 if (tail) *tail = key.substr(psize+1);
467 return true;
468 }
469 return false;
470}
471
472#ifdef LINUX_BUILD // Linux
473uint64_t GetTimeMs64()

Callers 3

matchFocusStringMethod · 0.85
listKeybindsMethod · 0.85
findPrefixInMapFunction · 0.85

Calls 3

sizeMethod · 0.45
dataMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected