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

Function stringFindAny

Sources/Shared/Containers/StringView.cpp:721–725  ·  view source on GitHub ↗

I don't want to include just for std::find_first_of() and unfortunately there's no equivalent in the C string library. Coming close are strpbrk() or strcspn() but both of them work with null-terminated strings, which is absolutely useless here, not to mention that both do *exactly* the same thing, with one returning a pointer but the other an offset, so what's the point

Source from the content-addressed store, hash-verified

719 for that case. Yes, std::string::find_first_of() probably would have that,
720 but I'd first need to allocate to make use of that and FUCK NO. */
721 const char* stringFindAny(const char* const data, const std::size_t size, const char* const characters, const std::size_t characterCount) {
722 for (const char* i = data, *end = data + size; i != end; ++i)
723 if (std::memchr(characters, *i, characterCount)) return i;
724 return {};
725 }
726
727 // Variants of the above. Not sure if those even have any vaguely corresponding C lib API. Probably not.
728

Callers 3

findAnyOrMethod · 0.85
containsAnyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected