MCPcopy Create free account
hub / github.com/apache/arrow / UTF8FindIfReverse

Function UTF8FindIfReverse

cpp/src/arrow/util/utf8_internal.h:471–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469// &*reverse_iterator(i) == &*(i + 1)
470template <class Predicate>
471static inline bool UTF8FindIfReverse(const uint8_t* first, const uint8_t* last,
472 Predicate&& predicate, const uint8_t** position) {
473 // converts to a normal point
474 const uint8_t* i = last - 1;
475 while (i >= first) {
476 uint32_t codepoint = 0;
477 const uint8_t* current = i;
478 if (ARROW_PREDICT_FALSE(!UTF8DecodeReverse(&i, &codepoint))) {
479 return false;
480 }
481 if (predicate(codepoint)) {
482 // converts normal pointer to 'reverse iterator semantics'.
483 *position = current + 1;
484 return true;
485 }
486 }
487 // similar to how an end pointer point to 1 beyond the last, reverse iterators point
488 // to the 'first' pointer to indicate out of range.
489 *position = first;
490 return true;
491}
492
493static inline bool UTF8AdvanceCodepoints(const uint8_t* first, const uint8_t* last,
494 const uint8_t** destination, int64_t n) {

Callers 4

TESTFunction · 0.85
TransformMethod · 0.85
TransformMethod · 0.85

Calls 1

UTF8DecodeReverseFunction · 0.85

Tested by 1

TESTFunction · 0.68