From 0bccada9d1c4c009cb3639637e31c42895be3122 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 1 Feb 2024 12:36:56 +0530 Subject: [PATCH] No longer need to abort after dealing with trailing bytes --- kitty/simd-string-impl.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kitty/simd-string-impl.h b/kitty/simd-string-impl.h index eae96fe0d..64ceb53fb 100644 --- a/kitty/simd-string-impl.h +++ b/kitty/simd-string-impl.h @@ -418,14 +418,12 @@ scalar_decode_all(UTF8Decoder *d, const uint8_t *src, size_t src_sz) { bool FUNC(utf8_decode_to_esc)(UTF8Decoder *d, const uint8_t *src, size_t src_sz) { // Based on the algorithm described in: https://woboq.com/blog/utf-8-processing-using-simd.html - d->output.pos = 0; d->num_consumed = 0; + if (d->state.cur != UTF8_ACCEPT) { - // Finish the trailing sequence only, we will be called again to process the rest allows use of aligned stores since output - // is not pre-filled. - d->num_consumed = scalar_decode_to_accept(d, src, src_sz); + // Finish the trailing sequence only + d->num_consumed += scalar_decode_to_accept(d, src, src_sz); src += d->num_consumed; src_sz -= d->num_consumed; - return false; } src_sz = MIN(src_sz, sizeof(integer_t)); integer_t vec = load_unaligned((integer_t*)src);