1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

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.
This commit is contained in:
Andy Wingo 2016-11-26 16:30:57 +01:00
parent 5a3bc32c99
commit 668153dbb6

View file

@ -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