| 469 | // &*reverse_iterator(i) == &*(i + 1) |
| 470 | template <class Predicate> |
| 471 | static 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 | |
| 493 | static inline bool UTF8AdvanceCodepoints(const uint8_t* first, const uint8_t* last, |
| 494 | const uint8_t** destination, int64_t n) { |