mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-22 07:21:06 +01:00
Merge pull request #5564 from harfbuzz/instancer-optimize-more2
[iup] Reuse more allocations
This commit is contained in:
4 files changed
+12
-12
No files matched your search
@@ -745,15 +745,11 @@ struct tuple_delta_t
|
||||
|
||||
if (opt_point_data.length + opt_deltas_data.length < point_data.length + deltas_data.length)
|
||||
{
|
||||
indices.fini ();
|
||||
indices = std::move (opt_indices);
|
||||
|
||||
if (is_comp_glyph_wo_deltas)
|
||||
{
|
||||
deltas_x.fini ();
|
||||
deltas_x = std::move (opt_deltas_x);
|
||||
|
||||
deltas_y.fini ();
|
||||
deltas_y = std::move (opt_deltas_y);
|
||||
}
|
||||
}
|
||||
@@ -1100,7 +1096,6 @@ struct TupleVariationData
|
||||
for (unsigned i = 0; i < out.length; i++)
|
||||
new_vars.push (std::move (out[i]));
|
||||
}
|
||||
tuple_vars.fini ();
|
||||
tuple_vars = std::move (new_vars);
|
||||
}
|
||||
return true;
|
||||
@@ -1216,9 +1211,9 @@ struct TupleVariationData
|
||||
return true;
|
||||
}
|
||||
|
||||
bool iup_optimize (const contour_point_vector_t& contour_points)
|
||||
bool iup_optimize (const contour_point_vector_t& contour_points,
|
||||
optimize_scratch_t &scratch)
|
||||
{
|
||||
optimize_scratch_t scratch;
|
||||
for (tuple_delta_t& var : tuple_vars)
|
||||
{
|
||||
if (!var.optimize (contour_points, is_composite, scratch))
|
||||
@@ -1230,6 +1225,7 @@ struct TupleVariationData
|
||||
public:
|
||||
bool instantiate (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location,
|
||||
const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances,
|
||||
optimize_scratch_t &scratch,
|
||||
contour_point_vector_t* contour_points = nullptr,
|
||||
bool optimize = false)
|
||||
{
|
||||
@@ -1251,7 +1247,7 @@ struct TupleVariationData
|
||||
if (!merge_tuple_variations (optimize ? contour_points : nullptr))
|
||||
return false;
|
||||
|
||||
if (optimize && !iup_optimize (*contour_points)) return false;
|
||||
if (optimize && !iup_optimize (*contour_points, scratch)) return false;
|
||||
return !tuple_vars.in_error ();
|
||||
}
|
||||
|
||||
@@ -1685,8 +1681,9 @@ struct item_variations_t
|
||||
bool instantiate_tuple_vars (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location,
|
||||
const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances)
|
||||
{
|
||||
optimize_scratch_t scratch;
|
||||
for (tuple_variations_t& tuple_vars : vars)
|
||||
if (!tuple_vars.instantiate (normalized_axes_location, axes_triple_distances))
|
||||
if (!tuple_vars.instantiate (normalized_axes_location, axes_triple_distances, scratch))
|
||||
return false;
|
||||
|
||||
if (!build_region_list ()) return false;
|
||||
|
||||
@@ -158,7 +158,8 @@ struct cvar
|
||||
tuple_variations))
|
||||
return_trace (false);
|
||||
|
||||
if (!tuple_variations.instantiate (c->plan->axes_location, c->plan->axes_triple_distances))
|
||||
optimize_scratch_t scratch;
|
||||
if (!tuple_variations.instantiate (c->plan->axes_location, c->plan->axes_triple_distances, scratch))
|
||||
return_trace (false);
|
||||
|
||||
if (!tuple_variations.compile_bytes (c->plan->axes_index_map, c->plan->axes_old_index_tag_map,
|
||||
|
||||
@@ -140,6 +140,7 @@ struct glyph_variations_t
|
||||
{
|
||||
unsigned count = plan->new_to_old_gid_list.length;
|
||||
bool iup_optimize = false;
|
||||
optimize_scratch_t scratch;
|
||||
iup_optimize = plan->flags & HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS;
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
@@ -147,7 +148,7 @@ struct glyph_variations_t
|
||||
contour_point_vector_t *all_points;
|
||||
if (!plan->new_gid_contour_points_map.has (new_gid, &all_points))
|
||||
return false;
|
||||
if (!glyph_variations[i].instantiate (plan->axes_location, plan->axes_triple_distances, all_points, iup_optimize))
|
||||
if (!glyph_variations[i].instantiate (plan->axes_location, plan->axes_triple_distances, scratch, all_points, iup_optimize))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -97,7 +97,8 @@ test_decompile_cvar ()
|
||||
hb_hashmap_t<hb_tag_t, TripleDistances> axes_triple_distances;
|
||||
axes_triple_distances.set (axis_tag, TripleDistances (1.0, 1.0));
|
||||
|
||||
tuple_variations.instantiate (normalized_axes_location, axes_triple_distances);
|
||||
OT::optimize_scratch_t scratch;
|
||||
tuple_variations.instantiate (normalized_axes_location, axes_triple_distances, scratch);
|
||||
|
||||
hb_always_assert (tuple_variations.tuple_vars[0].indices.length == 65);
|
||||
hb_always_assert (tuple_variations.tuple_vars[1].indices.length == 65);
|
||||
|
||||
Reference in new issue
Block a user