diff options
author | Andy Wingo <wingo@pobox.com> | 2016-11-26 16:30:57 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2016-11-26 16:30:57 +0100 |
commit | 668153dbb61040dc0f2d44e6653d4f7ed6e7c407 (patch) | |
tree | bc698c3952d0ad3901b808abf0b8f00f7a624ba4 | |
parent | 5a3bc32c9968a929158c2089b1bd65f922429f02 (diff) | |
download | guile-668153dbb61040dc0f2d44e6653d4f7ed6e7c407.tar.gz |
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.
-rw-r--r-- | libguile/weak-table.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libguile/weak-table.c b/libguile/weak-table.c index f6f8dd68b..1bb513b17 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 |