[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 03/04: Add weak-table fast path for update
From: |
Andy Wingo |
Subject: |
[Guile-commits] 03/04: Add weak-table fast path for update |
Date: |
Sun, 27 Nov 2016 20:11:05 +0000 (UTC) |
wingo pushed a commit to branch master
in repository guile.
commit 668153dbb61040dc0f2d44e6653d4f7ed6e7c407
Author: Andy Wingo <address@hidden>
Date: Sat Nov 26 16:30:57 2016 +0100
Add weak-table fast path for update
* libguile/weak-table.c (weak_table_put_x): If the key is the same and
the table is weak-key, avoid re-setting disappearing links.
---
libguile/weak-table.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libguile/weak-table.c b/libguile/weak-table.c
index f6f8dd6..1bb513b 100644
--- a/libguile/weak-table.c
+++ b/libguile/weak-table.c
@@ -686,6 +686,16 @@ weak_table_put_x (scm_t_weak_table *table, unsigned long
hash,
}
}
+ /* Fast path for updated values for existing entries of weak-key
+ tables. */
+ if (table->kind == SCM_WEAK_TABLE_KIND_KEY &&
+ entries[k].hash == hash &&
+ entries[k].key == SCM_UNPACK (key))
+ {
+ entries[k].value = SCM_UNPACK (value);
+ return;
+ }
+
if (entries[k].hash)
unregister_disappearing_links (&entries[k], table->kind);
else