From 39048099cb421095e24cdcc027b9cdc2a7fcf93e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 1 Aug 2023 19:41:12 -0600 Subject: [PATCH] [skippy-iter] Remove early stop The optimization in (Chain)RuleSet matching relies on matching one, even if num_items is out of range. Fixes https://github.com/harfbuzz/harfbuzz/issues/4358 --- src/hb-ot-layout-gsubgpos.hh | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index f46fb4e03..73e79a502 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -584,11 +584,7 @@ struct hb_ot_apply_context_t : bool next (unsigned *unsafe_to = nullptr) { assert (num_items > 0); - /* The alternate condition below is faster at string boundaries, - * but produces subpar "unsafe-to-concat" values. */ - signed stop = (signed) end - (signed) num_items; - if (c->buffer->flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT) - stop = (signed) end - 1; + const signed stop = (signed) end - 1; while ((signed) idx < stop) { idx++; @@ -620,11 +616,7 @@ struct hb_ot_apply_context_t : bool prev (unsigned *unsafe_from = nullptr) { assert (num_items > 0); - /* The alternate condition below is faster at string boundaries, - * but produces subpar "unsafe-to-concat" values. */ - unsigned stop = num_items - 1; - if (c->buffer->flags & HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT) - stop = 1 - 1; + const unsigned stop = 0; while (idx > stop) { idx--;