* [PATCH] id_table: wip - use ID shift
@ 2015-11-04 21:04 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-11-04 21:04 UTC (permalink / raw)
To: spew
This allows all IDs, including ivar IDs to be used in id_table
while (hopefully) preserving good behavior without the scope
bits hurting hashing.
---
id_table.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/id_table.c b/id_table.c
index 13adf6b..37f26fa 100644
--- a/id_table.c
+++ b/id_table.c
@@ -30,10 +30,11 @@
* 33: array(12) (capa <= 64) + hash(22)
* 34: array(14) (capa <= 64) + hash(22)
* 34: array(15) (capa <= 64) + hash(22)
+ * 44: array(15) (capa <= 64) + hash(22), but shifted IDs
*/
#ifndef ID_TABLE_IMPL
-#define ID_TABLE_IMPL 34
+#define ID_TABLE_IMPL 44
#endif
#if ID_TABLE_IMPL == 0
@@ -179,6 +180,20 @@
#define ID_TABLE_USE_SMALL_HASH 1
+#elif ID_TABLE_IMPL == 44
+#define ID_TABLE_NAME mix
+#define ID_TABLE_IMPL_TYPE struct mix_id_table
+
+#define ID_TABLE_USE_MIX 1
+#define ID_TABLE_USE_MIX_LIST_MAX_CAPA 64
+
+#define ID_TABLE_USE_ID_SHIFT 1
+
+#define ID_TABLE_USE_LIST 1
+#define ID_TABLE_USE_CALC_VALUES 1
+#define ID_TABLE_USE_LIST_SORTED 1
+
+#define ID_TABLE_USE_SMALL_HASH 1
#else
#error
#endif
@@ -208,7 +223,22 @@ UNUSED(int IMPL(_delete)(ID_TABLE_IMPL_TYPE *, ID));
UNUSED(void IMPL(_foreach)(ID_TABLE_IMPL_TYPE *, rb_id_table_foreach_func_t *, void *));
UNUSED(void IMPL(_foreach_values)(ID_TABLE_IMPL_TYPE *, rb_id_table_foreach_values_func_t *, void *));
-#if ID_TABLE_USE_ID_SERIAL
+#if ID_TABLE_USE_ID_SHIFT
+typedef ID id_key_t;
+#define ID_LBITS ((CHAR_BIT * sizeof(ID)) - ID_SCOPE_SHIFT)
+
+static inline ID
+key2id(id_key_t key)
+{
+ return (key << ID_SCOPE_SHIFT) | (key >> ID_LBITS);
+}
+
+static inline id_key_t
+id2key(ID id)
+{
+ return (id << ID_LBITS) | (id >> ID_SCOPE_SHIFT);
+}
+#elif ID_TABLE_USE_ID_SERIAL
typedef rb_id_serial_t id_key_t;
static inline ID
key2id(id_key_t key)
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-11-04 21:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-04 21:04 [PATCH] id_table: wip - use ID shift Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).