From 225ed707376c95b4da6a9fe21a7a91f6687dce97 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 26 Sep 2024 22:38:24 +0200 Subject: [PATCH] html: Accelerate htmlParseCharData --- HTMLparser.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/HTMLparser.c b/HTMLparser.c index cf7bab5f..651eac9f 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -3035,6 +3035,29 @@ htmlParseCharData(htmlParserCtxtPtr ctxt) { } } + /* Accelerator */ + if (!ncr) { + while (avail > 0) { + static const unsigned mask[8] = { + 0x00002401, 0x10002040, + 0x00000000, 0x00000000, + 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF + }; + cur = *in; + if ((1u << (cur & 0x1F)) & mask[cur >> 5]) + break; + col += 1; + in += 1; + avail -= 1; + } + + if ((!eof) && (avail <= 64)) + continue; + if (avail == 0) + continue; + } + cur = *in; size = 1; col += 1;