From 3e4a25098df348c459f57829d84c4b0ebb3efc97 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 6 Dec 2021 16:00:15 -0800 Subject: [PATCH] [repacker] add a maximum number of roots that can be moved in one iteration. Set to half of the roots in a space. This prevents the repacker from moving all roots in a space to a new space if their are overflows in every root. --- src/hb-repacker.hh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh index 862ab6b78..a49e8e54b 100644 --- a/src/hb-repacker.hh +++ b/src/hb-repacker.hh @@ -745,15 +745,6 @@ struct graph_t return space_for (node.parents[0], root); } - void roots_with_space (unsigned space, hb_set_t* roots) const - { - for (unsigned i = 0; i < vertices_.length; i++) { - if (vertices_[i].space == space) { - roots->add (i); - } - } - } - void err_other_error () { this->successful = false; } private: @@ -1104,6 +1095,7 @@ static bool _try_isolating_subgraphs (const hb_vector_t maximum_to_move) { + // Only move at most half of the roots in a space at a time. + unsigned extra = roots_to_isolate.get_population () - maximum_to_move; + while (extra--) { + unsigned root = HB_SET_VALUE_INVALID; + roots_to_isolate.previous (&root); + roots_to_isolate.del (root); + } + } + DEBUG_MSG (SUBSET_REPACK, nullptr, "Overflow in space %d (%d roots). Moving %d roots to space %d.", space,