| 628 | } |
| 629 | |
| 630 | StringVal StringFunctions::Reverse(FunctionContext* context, const StringVal& str) { |
| 631 | if (str.is_null) return StringVal::null(); |
| 632 | if (context->impl()->GetConstFnAttr(FunctionContextImpl::UTF8_MODE)) { |
| 633 | return Utf8Reverse(context, str); |
| 634 | } |
| 635 | StringVal result(context, str.len); |
| 636 | if (UNLIKELY(result.is_null)) return StringVal::null(); |
| 637 | BitUtil::ByteSwap(result.ptr, str.ptr, str.len); |
| 638 | return result; |
| 639 | } |
| 640 | |
| 641 | static inline void InPlaceReverse(uint8_t* ptr, int len) { |
| 642 | for (int i = 0, j = len - 1; i < j; ++i, --j) { |
nothing calls this directly
no test coverage detected