[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed May 30 00:09:40 UTC 2018
src/hb-map-private.hh | 29 +++++++++++++++++++++--------
src/hb-map.cc | 43 +++++++++++++++++++++++++++++++++++++++++++
src/hb-map.h | 17 +++++++++--------
3 files changed, 73 insertions(+), 16 deletions(-)
New commits:
commit 661e9ae4a55c198eb9fdb2c104979dd55a0fa1f1
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 29 17:09:17 2018 -0700
[map] Add clear(), is_empty(), and get_population()
diff --git a/src/hb-map-private.hh b/src/hb-map-private.hh
index 7611021a..64bcffc2 100644
--- a/src/hb-map-private.hh
+++ b/src/hb-map-private.hh
@@ -66,8 +66,7 @@ struct hb_map_t
inline void init_shallow (void)
{
in_error = false;
- population = 0;
- occupancy = 0;
+ population = occupancy = 0;
mask = 0;
prime = 0;
items = nullptr;
@@ -105,8 +104,7 @@ struct hb_map_t
item_t *old_items = items;
/* Switch to new, empty, array. */
- population = 0;
- occupancy = 0;
+ population = occupancy = 0;
mask = new_size - 1;
prime = prime_for (power);
items = new_items;
@@ -167,6 +165,22 @@ struct hb_map_t
static const hb_codepoint_t INVALID = HB_MAP_VALUE_INVALID;
+ inline void clear (void)
+ {
+ memset (items, 0xFF, ((size_t) mask + 1) * sizeof (item_t));
+ population = occupancy = 0;
+ }
+
+ inline bool is_empty (void) const
+ {
+ return population != 0;
+ }
+
+ inline unsigned int get_population () const
+ {
+ return population;
+ }
+
protected:
static HB_INTERNAL unsigned int prime_for (unsigned int shift);
diff --git a/src/hb-map.cc b/src/hb-map.cc
index a317d9c5..702a926e 100644
--- a/src/hb-map.cc
+++ b/src/hb-map.cc
@@ -228,6 +228,49 @@ hb_map_has (const hb_map_t *map,
}
+/**
+ * hb_map_clear:
+ * @map: a map.
+ *
+ *
+ *
+ * Since: REPLACEME
+ **/
+void
+hb_map_clear (hb_map_t *map)
+{
+ return map->clear ();
+}
+
+/**
+ * hb_map_is_empty:
+ * @map: a map.
+ *
+ *
+ *
+ * Since: REPLACEME
+ **/
+hb_bool_t
+hb_map_is_empty (const hb_map_t *map)
+{
+ return map->is_empty ();
+}
+
+/**
+ * hb_map_get_population:
+ * @map: a map.
+ *
+ *
+ *
+ * Since: REPLACEME
+ **/
+unsigned int
+hb_map_get_population (const hb_map_t *map)
+{
+ return map->get_population ();
+}
+
+
/* Following comment and table copied from glib. */
/* Each table size has an associated prime modulo (the first prime
* lower than the table size) used to find the initial bucket. Probing
diff --git a/src/hb-map.h b/src/hb-map.h
index e24bfc4f..61822830 100644
--- a/src/hb-map.h
+++ b/src/hb-map.h
@@ -73,14 +73,6 @@ HB_EXTERN hb_bool_t
hb_map_allocation_successful (const hb_map_t *map);
/*
- HB_EXTERN void
- hb_map_clear (hb_map_t *map);
-
- HB_EXTERN hb_bool_t
- hb_map_is_empty (const hb_map_t *map);
-
- HB_EXTERN unsigned int
- hb_map_get_population (const hb_map_t *map);
HB_EXTERN hb_bool_t
hb_map_is_equal (const hb_map_t *map,
@@ -88,6 +80,15 @@ hb_map_allocation_successful (const hb_map_t *map);
*/
HB_EXTERN void
+hb_map_clear (hb_map_t *map);
+
+HB_EXTERN hb_bool_t
+hb_map_is_empty (const hb_map_t *map);
+
+HB_EXTERN unsigned int
+hb_map_get_population (const hb_map_t *map);
+
+HB_EXTERN void
hb_map_set (hb_map_t *map,
hb_codepoint_t key,
hb_codepoint_t value);
commit b6959c33e23b464ddbe5fe98fafc80bbb669189c
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue May 29 17:02:22 2018 -0700
[map] Minor
diff --git a/src/hb-map-private.hh b/src/hb-map-private.hh
index 07d5d0da..7611021a 100644
--- a/src/hb-map-private.hh
+++ b/src/hb-map-private.hh
@@ -132,12 +132,11 @@ struct hb_map_t
return; /* Trying to delete non-existent key. */
/* Accounting. */
- if (items[i].is_tombstone ())
- occupancy--;
- else if (!items[i].is_unused ())
+ if (!items[i].is_unused ())
{
- population--;
occupancy--;
+ if (items[i].value != INVALID)
+ population--;
}
occupancy++;
if (value != INVALID)
More information about the HarfBuzz
mailing list