[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hash: declare some functions with the warn_unused_result att

From: Ben Pfaff
Subject: Re: [PATCH] hash: declare some functions with the warn_unused_result attribute
Date: Tue, 16 Jun 2009 09:30:09 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Eric Blake <address@hidden> writes:

> There might also be alternative implementations possible with
> better performance.  For example, instead of malloc'ing free
> entries one at a time and tracking bucket overflows as pointers
> to malloc'd objects, we could instead malloc/realloc an array
> of overflows, with bucket overflows tracked as indices into
> that array.

An approach that is even better than allocating groups of entries
is to make the hash table's client allocate the entries as part
of the data items that it intends to put into the hash table.
Then you completely get rid of an allocation, instead of just
amortizing it.

GNU PSPP has a hash table library that supports this model.  The
header file has a lot of details on how it works:

Of course, this would require an interface change, so I wouldn't
expect gnulib's hash table to switch to this model.  But it might
be worth supporting as an alternative.
Only wimps use tape backup: _real_ men just upload their important stuff
on ftp, and let the rest of the world mirror it ;)
        -- Linus Torvalds

reply via email to

[Prev in Thread] Current Thread [Next in Thread]