Use more vector resize_exact

pull/4004/head
Behdad Esfahbod 2 years ago
parent b6be455020
commit 8f2345ca36
  1. 7
      src/hb-bit-set.hh
  2. 6
      src/hb-cff2-interp-cs.hh

@ -88,9 +88,7 @@ struct hb_bit_set_t
bool resize (unsigned int count, bool clear = true) bool resize (unsigned int count, bool clear = true)
{ {
if (unlikely (!successful)) return false; if (unlikely (!successful)) return false;
pages.alloc (count, true); /* Exact allocation. */ if (unlikely (!pages.resize (count, clear, true) || !page_map.resize (count, clear, true)))
page_map.alloc (count, true); /* Exact allocation. */
if (unlikely (!pages.resize (count, clear) || !page_map.resize (count, clear)))
{ {
pages.resize (page_map.length); pages.resize (page_map.length);
successful = false; successful = false;
@ -424,8 +422,7 @@ struct hb_bit_set_t
private: private:
bool allocate_compact_workspace (hb_vector_t<unsigned>& workspace) bool allocate_compact_workspace (hb_vector_t<unsigned>& workspace)
{ {
workspace.alloc (pages.length, true); if (unlikely (!workspace.resize_exact (pages.length)))
if (unlikely (!workspace.resize (pages.length)))
{ {
successful = false; successful = false;
return false; return false;

@ -45,8 +45,7 @@ struct blend_arg_t : number_t
numValues = numValues_; numValues = numValues_;
valueIndex = valueIndex_; valueIndex = valueIndex_;
unsigned numBlends = blends_.length; unsigned numBlends = blends_.length;
deltas.alloc (numBlends, true); /* Exact-size allocation. */ if (unlikely (!deltas.resize_exact (numBlends)))
if (unlikely (!deltas.resize (numBlends)))
return; return;
for (unsigned int i = 0; i < numBlends; i++) for (unsigned int i = 0; i < numBlends; i++)
deltas.arrayZ[i] = blends_.arrayZ[i]; deltas.arrayZ[i] = blends_.arrayZ[i];
@ -119,8 +118,7 @@ struct cff2_cs_interp_env_t : cs_interp_env_t<ELEM, CFF2Subrs>
region_count = varStore->varStore.get_region_index_count (get_ivs ()); region_count = varStore->varStore.get_region_index_count (get_ivs ());
if (do_blend) if (do_blend)
{ {
scalars.alloc (region_count, true); if (unlikely (!scalars.resize_exact (region_count)))
if (unlikely (!scalars.resize (region_count)))
SUPER::set_error (); SUPER::set_error ();
else else
varStore->varStore.get_region_scalars (get_ivs (), coords, num_coords, varStore->varStore.get_region_scalars (get_ivs (), coords, num_coords,

Loading…
Cancel
Save