[Git][ghc/ghc][master] rts/Hash: Don't iterate over chunks if we don't need to free data
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Sat Feb 17 11:03:37 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
4ab48edb by Ben Gamari at 2024-02-17T06:02:21-05:00
rts/Hash: Don't iterate over chunks if we don't need to free data
When freeing a `HashTable` there is no reason to walk over the hash list
before freeing it if the user has not given us a `dataFreeFun`.
Noticed while looking at #24410.
- - - - -
1 changed file:
- rts/Hash.c
Changes:
=====================================
rts/Hash.c
=====================================
@@ -440,14 +440,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/4ab48edbf37a72162dd3e9143a9cd5d13cd82c56
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ab48edbf37a72162dd3e9143a9cd5d13cd82c56
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/20240217/9246d5ae/attachment-0001.html>
More information about the ghc-commits
mailing list