[buffer/set/map] Move immutable check only to C API boundary

The immutable objects are a concept only enforced by the C API.
So move checks only to that region.

This does assume that the rest of the code is careful not getting
into these internal methods on immutable objects, which something
we do, but have no way of enforcing (currently).

.
pull/2872/head
Behdad Esfahbod 5 years ago
parent 985329b7c7
commit 08ed9e3f77
  1. 21
      src/hb-buffer.cc
  2. 3
      src/hb-map.cc
  3. 4
      src/hb-map.hh
  4. 3
      src/hb-set.cc
  5. 5
      src/hb-set.hh

@ -218,9 +218,6 @@ hb_buffer_t::get_scratch_buffer (unsigned int *size)
void
hb_buffer_t::reset ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
hb_unicode_funcs_destroy (unicode);
unicode = hb_unicode_funcs_reference (hb_unicode_funcs_get_default ());
flags = HB_BUFFER_FLAG_DEFAULT;
@ -233,9 +230,6 @@ hb_buffer_t::reset ()
void
hb_buffer_t::clear ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT;
props = default_props;
scratch_flags = HB_BUFFER_SCRATCH_FLAG_DEFAULT;
@ -290,9 +284,6 @@ hb_buffer_t::add_info (const hb_glyph_info_t &glyph_info)
void
hb_buffer_t::remove_output ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
have_output = false;
have_positions = false;
@ -303,9 +294,6 @@ hb_buffer_t::remove_output ()
void
hb_buffer_t::clear_output ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
have_output = true;
have_positions = false;
@ -316,9 +304,6 @@ hb_buffer_t::clear_output ()
void
hb_buffer_t::clear_positions ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
have_output = false;
have_positions = true;
@ -1226,6 +1211,9 @@ hb_buffer_get_invisible_glyph (hb_buffer_t *buffer)
void
hb_buffer_reset (hb_buffer_t *buffer)
{
if (unlikely (hb_object_is_immutable (buffer)))
return;
buffer->reset ();
}
@ -1241,6 +1229,9 @@ hb_buffer_reset (hb_buffer_t *buffer)
void
hb_buffer_clear_contents (hb_buffer_t *buffer)
{
if (unlikely (hb_object_is_immutable (buffer)))
return;
buffer->clear ();
}

@ -253,6 +253,9 @@ hb_map_has (const hb_map_t *map,
void
hb_map_clear (hb_map_t *map)
{
if (unlikely (hb_object_is_immutable (map)))
return;
return map->clear ();
}

@ -97,8 +97,6 @@ struct hb_hashmap_t
void reset ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
successful = true;
clear ();
}
@ -171,8 +169,6 @@ struct hb_hashmap_t
void clear ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
if (items)
for (auto &_ : hb_iter (items, mask + 1))
_.clear ();

@ -183,6 +183,9 @@ hb_set_allocation_successful (const hb_set_t *set)
void
hb_set_clear (hb_set_t *set)
{
if (unlikely (hb_object_is_immutable (set)))
return;
set->clear ();
}

@ -256,17 +256,12 @@ struct hb_set_t
void reset ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
successful = true;
clear ();
}
void clear ()
{
if (unlikely (hb_object_is_immutable (this)))
return;
if (resize (0))
population = 0;
}

Loading…
Cancel
Save