From 7005d50b4b51408cd5eb1900ab5e355095664d9f Mon Sep 17 00:00:00 2001 From: hunt Date: Mon, 22 Jan 2007 16:54:18 +0000 Subject: [PATCH] 2007-01-22 Martin Hunt * map-gen.c (_stp_map_exists): New. Check for membership only. --- runtime/ChangeLog | 4 ++++ runtime/map-gen.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index d14c5b8f7..bee42c6dc 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,7 @@ +2007-01-22 Martin Hunt + + * map-gen.c (_stp_map_exists): New. Check for membership only. + 2007-01-19 Josh Stone PR 3079 diff --git a/runtime/map-gen.c b/runtime/map-gen.c index f2b39d40f..13c24d76b 100644 --- a/runtime/map-gen.c +++ b/runtime/map-gen.c @@ -524,6 +524,41 @@ int KEYSYM(_stp_map_del) (MAP map, ALLKEYSD(key)) return 0; } +int KEYSYM(_stp_map_exists) (MAP map, ALLKEYSD(key)) +{ + unsigned int hv; + struct hlist_head *head; + struct hlist_node *e; + struct KEYSYM(map_node) *n; + + if (map == NULL) + return 0; + + hv = KEYSYM(hash) (ALLKEYS(key)); + head = &map->hashes[hv]; + + hlist_for_each(e, head) { + n = (struct KEYSYM(map_node) *)((long)e - sizeof(struct list_head)); + if (KEY1_EQ_P(n->key1, key1) +#if KEY_ARITY > 1 + && KEY2_EQ_P(n->key2, key2) +#if KEY_ARITY > 2 + && KEY3_EQ_P(n->key3, key3) +#if KEY_ARITY > 3 + && KEY4_EQ_P(n->key4, key4) +#if KEY_ARITY > 4 + && KEY5_EQ_P(n->key5, key5) +#endif +#endif +#endif +#endif + ) { + return 1; + } + } + /* key not found */ + return 0; +} #undef KEY1NAME #undef KEY1N -- 2.43.5