mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-29 01:23:56 +01:00
[multimap] Use one fewer object
Also fix error-checking to check for sub-object errors.
This commit is contained in:
1 parent
280edb909b
commit
f839bd11d2
1 file changed
+14
-15
+14
-15
@@ -38,10 +38,10 @@ struct hb_multimap_t
|
||||
{
|
||||
void add (hb_codepoint_t k, hb_codepoint_t v)
|
||||
{
|
||||
hb_codepoint_t *i;
|
||||
if (multiples_indices.has (k, &i))
|
||||
hb_vector_t<hb_codepoint_t> *m;
|
||||
if (multiples.has (k, &m))
|
||||
{
|
||||
multiples_values[*i].push (v);
|
||||
m->push (v);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,12 +51,7 @@ struct hb_multimap_t
|
||||
hb_codepoint_t old = *old_v;
|
||||
singulars.del (k);
|
||||
|
||||
multiples_indices.set (k, multiples_values.length);
|
||||
auto *vec = multiples_values.push ();
|
||||
|
||||
vec->push (old);
|
||||
vec->push (v);
|
||||
|
||||
multiples.set (k, hb_vector_t<hb_codepoint_t> {old, v});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,16 +64,21 @@ struct hb_multimap_t
|
||||
if (singulars.has (k, &v))
|
||||
return hb_array (v, 1);
|
||||
|
||||
hb_codepoint_t *i;
|
||||
if (multiples_indices.has (k, &i))
|
||||
return multiples_values[*i].as_array ();
|
||||
hb_vector_t<hb_codepoint_t> *m;
|
||||
if (multiples.has (k, &m))
|
||||
return m->as_array ();
|
||||
|
||||
return hb_array_t<const hb_codepoint_t> ();
|
||||
}
|
||||
|
||||
bool in_error () const
|
||||
{
|
||||
return singulars.in_error () || multiples_indices.in_error () || multiples_values.in_error ();
|
||||
if (singulars.in_error () || multiples.in_error ())
|
||||
return true;
|
||||
for (const auto &m : multiples.values_ref ())
|
||||
if (m.in_error ())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void resize (unsigned size)
|
||||
@@ -88,8 +88,7 @@ struct hb_multimap_t
|
||||
|
||||
protected:
|
||||
hb_map_t singulars;
|
||||
hb_map_t multiples_indices;
|
||||
hb_vector_t<hb_vector_t<hb_codepoint_t>> multiples_values;
|
||||
hb_hashmap_t<hb_codepoint_t, hb_vector_t<hb_codepoint_t>> multiples;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user