[vector] Add resize_exact()
This commit is contained in:
parent
a516ce97e0
commit
b6be455020
|
@ -235,8 +235,7 @@ struct subr_flattener_t
|
|||
bool flatten (str_buff_vec_t &flat_charstrings)
|
||||
{
|
||||
unsigned count = plan->num_output_glyphs ();
|
||||
flat_charstrings.alloc (count, true);
|
||||
if (!flat_charstrings.resize (count))
|
||||
if (!flat_charstrings.resize_exact (count))
|
||||
return false;
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -271,8 +270,7 @@ struct subr_closures_t
|
|||
{
|
||||
subr_closures_t (unsigned int fd_count) : global_closure (), local_closures ()
|
||||
{
|
||||
local_closures.alloc (fd_count, true);
|
||||
local_closures.resize (fd_count);
|
||||
local_closures.resize_exact (fd_count);
|
||||
}
|
||||
|
||||
void reset ()
|
||||
|
@ -620,15 +618,12 @@ struct subr_subsetter_t
|
|||
if (cff_accelerator) {
|
||||
// If we are not dropping hinting then charstrings are not modified so we can
|
||||
// just use a reference to the cached copies.
|
||||
cached_charstrings.alloc (plan->num_output_glyphs (), true);
|
||||
cached_charstrings.resize (plan->num_output_glyphs ());
|
||||
cached_charstrings.resize_exact (plan->num_output_glyphs ());
|
||||
parsed_global_subrs = &cff_accelerator->parsed_global_subrs;
|
||||
parsed_local_subrs = &cff_accelerator->parsed_local_subrs;
|
||||
} else {
|
||||
parsed_charstrings.alloc (plan->num_output_glyphs (), true);
|
||||
parsed_charstrings.resize (plan->num_output_glyphs ());
|
||||
parsed_global_subrs_storage.alloc (acc.globalSubrs->count, true);
|
||||
parsed_global_subrs_storage.resize (acc.globalSubrs->count);
|
||||
parsed_charstrings.resize_exact (plan->num_output_glyphs ());
|
||||
parsed_global_subrs_storage.resize_exact (acc.globalSubrs->count);
|
||||
|
||||
if (unlikely (!parsed_local_subrs_storage.resize (fd_count))) return false;
|
||||
|
||||
|
@ -740,8 +735,7 @@ struct subr_subsetter_t
|
|||
|
||||
bool encode_charstrings (str_buff_vec_t &buffArray) const
|
||||
{
|
||||
buffArray.alloc (plan->num_output_glyphs (), true);
|
||||
if (unlikely (!buffArray.resize (plan->num_output_glyphs ())))
|
||||
if (unlikely (!buffArray.resize_exact (plan->num_output_glyphs ())))
|
||||
return false;
|
||||
for (unsigned int i = 0; i < plan->num_output_glyphs (); i++)
|
||||
{
|
||||
|
@ -765,8 +759,7 @@ struct subr_subsetter_t
|
|||
{
|
||||
unsigned int count = remap.get_population ();
|
||||
|
||||
buffArray.alloc (count, true);
|
||||
if (unlikely (!buffArray.resize (count)))
|
||||
if (unlikely (!buffArray.resize_exact (count)))
|
||||
return false;
|
||||
for (unsigned int new_num = 0; new_num < count; new_num++)
|
||||
{
|
||||
|
|
|
@ -401,10 +401,10 @@ struct hb_vector_t
|
|||
return true;
|
||||
}
|
||||
|
||||
bool resize (int size_, bool initialize = true)
|
||||
bool resize (int size_, bool initialize = true, bool exact = false)
|
||||
{
|
||||
unsigned int size = size_ < 0 ? 0u : (unsigned int) size_;
|
||||
if (!alloc (size))
|
||||
if (!alloc (size, exact))
|
||||
return false;
|
||||
|
||||
if (size > length)
|
||||
|
@ -421,6 +421,10 @@ struct hb_vector_t
|
|||
length = size;
|
||||
return true;
|
||||
}
|
||||
bool resize_exact (int size_, bool initialize = true)
|
||||
{
|
||||
return resize (size_, initialize, true);
|
||||
}
|
||||
|
||||
Type pop ()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue