From 2f1fe3209c99e7003b79974416a6069161dd835d Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:28:43 +0100 Subject: [PATCH] Use a direct statically-known call for decoding in the fast path --- ext/dom/html_document.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/dom/html_document.c b/ext/dom/html_document.c index fd0337fb20d..f684f449f6f 100644 --- a/ext/dom/html_document.c +++ b/ext/dom/html_document.c @@ -511,7 +511,8 @@ static bool dom_decode_encode_fast_path( const lxb_char_t *last_output = buf_ref; while (buf_ref != buf_end) { const lxb_char_t *buf_ref_backup = buf_ref; - lxb_codepoint_t codepoint = decoding_encoding_ctx->decode_data->decode_single(&decoding_encoding_ctx->decode, &buf_ref, buf_end); + /* Fast path converts non-validated UTF-8 -> validated UTF-8 */ + lxb_codepoint_t codepoint = lxb_encoding_decode_utf_8_single(&decoding_encoding_ctx->decode, &buf_ref, buf_end); if (UNEXPECTED(codepoint > LXB_ENCODING_MAX_CODEPOINT)) { size_t skip = buf_ref - buf_ref_backup; /* Skip invalid data, it's replaced by the UTF-8 replacement bytes */ if (!dom_process_parse_chunk(