[Git][ghc/ghc][wip/tvar-table] rts/Hash: Don't iterate over chunks if we don't need to free data
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Tue Feb 6 18:16:54 UTC 2024
Ben Gamari pushed to branch wip/tvar-table at Glasgow Haskell Compiler / GHC
Commits:
97b6d1b8 by Ben Gamari at 2024-02-06T13:15:38-05:00
rts/Hash: Don't iterate over chunks if we don't need to free data
If the user has not given us a dataFreeFun then there is no need
for us to walk over the hash list before freeing it.
- - - - -
1 changed file:
- rts/Hash.c
Changes:
=====================================
rts/Hash.c
=====================================
@@ -442,14 +442,15 @@ freeHashTable(HashTable *table, void (*freeDataFun)(void *) )
/* Free table segments */
while (segment >= 0) {
- while (index >= 0) {
- HashList *next;
- for (HashList *hl = table->dir[segment][index]; hl != NULL; hl = next) {
- next = hl->next;
- if (freeDataFun != NULL)
+ if (freeDataFun) {
+ while (index >= 0) {
+ HashList *next;
+ for (HashList *hl = table->dir[segment][index]; hl != NULL; hl = next) {
+ next = hl->next;
(*freeDataFun)((void *) hl->data);
+ }
+ index--;
}
- index--;
}
stgFree(table->dir[segment]);
segment--;
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97b6d1b867224090565c6ab271c85be1cdcf46c0
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97b6d1b867224090565c6ab271c85be1cdcf46c0
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240206/c9c7ef05/attachment-0001.html>
More information about the ghc-commits
mailing list