MCPcopy Create free account
hub / github.com/Snapchat/Valdi / processCharacters

Function processCharacters

valdi_core/src/valdi_core/cpp/Text/CharacterSet.cpp:57–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55
56template<typename F>
57static void processCharacters(const CharacterRange* ranges, size_t length, F&& fn) {
58 std::optional<uint32_t> lastOffsetIndex;
59 uint32_t bitsetsCount = 0;
60
61 for (size_t i = 0; i < length; i++) {
62 const auto& range = ranges[i];
63
64 auto from = range.from;
65 auto to = range.to;
66 for (uint32_t j = from; j <= to; j++) {
67 auto offsetIndex = j >> kOffsetShift;
68 auto offsetValue = j & kOffsetMask;
69 if (!lastOffsetIndex || lastOffsetIndex.value() != offsetIndex) {
70 lastOffsetIndex = {offsetIndex};
71 bitsetsCount++;
72 }
73
74 fn(offsetIndex, bitsetsCount, offsetValue);
75 }
76 }
77}
78
79void CharacterSet::initializeBitsets(
80 const CharacterRange* ranges, size_t length, uint32_t minOffset, uint16_t* offsets, CharacterSet::Bitset* bitsets) {

Callers 2

initializeBitsetsMethod · 0.85
makeMethod · 0.85

Calls 2

valueMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected