From 5b04b40dd55bfd9308875cf82b6ded3e1b42a22f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 16 Sep 2025 16:52:53 -0600 Subject: [PATCH] [instancer/tuplevars] Allocate compiled_deltas from alloc pool --- src/hb-ot-var-common.hh | 15 +++++++++------ src/hb-vector.hh | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index d22181565..5dedff1f1 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -547,14 +547,16 @@ struct tuple_delta_t return compiled_interm_coords.length; } - bool compile_deltas (hb_vector_t &rounded_deltas_scratch) - { return compile_deltas (indices, deltas_x, deltas_y, compiled_deltas, rounded_deltas_scratch); } + bool compile_deltas (hb_vector_t &rounded_deltas_scratch, + hb_alloc_pool_t *pool = nullptr) + { return compile_deltas (indices, deltas_x, deltas_y, compiled_deltas, rounded_deltas_scratch, pool); } static bool compile_deltas (hb_array_t point_indices, hb_array_t x_deltas, hb_array_t y_deltas, hb_vector_t &compiled_deltas, /* OUT */ - hb_vector_t &rounded_deltas /* scratch */) + hb_vector_t &rounded_deltas, /* scratch */ + hb_alloc_pool_t *pool = nullptr) { if (unlikely (!rounded_deltas.resize_dirty (point_indices.length))) return false; @@ -573,7 +575,7 @@ struct tuple_delta_t if (y_deltas) alloc_len *= 2; - if (unlikely (!compiled_deltas.resize_dirty (alloc_len))) return false; + if (unlikely (!compiled_deltas.allocate_from_pool (pool, alloc_len, false))) return false; unsigned encoded_len = compile_deltas (compiled_deltas, rounded_deltas); @@ -594,7 +596,8 @@ struct tuple_delta_t if (j != rounded_deltas.length) return false; encoded_len += compile_deltas (compiled_deltas.as_array ().sub_array (encoded_len), rounded_deltas); } - return compiled_deltas.resize (encoded_len); + compiled_deltas.shrink (encoded_len); + return true; } static unsigned compile_deltas (hb_array_t encoded_bytes, @@ -1313,7 +1316,7 @@ struct TupleVariationData * this tuple */ if (!points_data->length) continue; - if (!tuple.compile_deltas (rounded_deltas_scratch)) + if (!tuple.compile_deltas (rounded_deltas_scratch, pool)) return false; unsigned points_data_length = (points_data != shared_points_bytes) ? points_data->length : 0; diff --git a/src/hb-vector.hh b/src/hb-vector.hh index e6cc08a1c..d24ae0b6b 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -545,9 +545,9 @@ struct hb_vector_t HB_ALWAYS_INLINE_VECTOR_ALLOCS bool allocate_from_pool (allocator_t *allocator, unsigned size, unsigned int initialize = true) { - assert (!length && !allocated); if (allocator) { + assert (!length && !allocated); arrayZ = (Type *) allocator->alloc (size * sizeof (Type)); if (unlikely (!arrayZ)) {