pkghash improvements/modifications
commit0b9cd9448c16dcf5e21ee8822698dbe908db520f
authorDan McGee <dan@archlinux.org>
Mon, 2 Jan 2012 19:29:40 +0000 (2 13:29 -0600)
committerDan McGee <dan@archlinux.org>
Tue, 3 Jan 2012 01:41:42 +0000 (2 19:41 -0600)
tree51061eb85fe69c880cf2497977102e022484152f
parent177beb91c96a078f729bd11c2f6c1144082e69e3
pkghash improvements/modifications

This patch changes a variety of small things related to our pkghash
implementation with an eye toward performance, especially on native
32-bit systems.

* Use `unsigned int` rather than `size_t` for hash sizes. We already
  return ERANGE for any attempted creation of a hash greater than 1
  million elements, so unsigned int is more than large enough for our
  purposes. Switching to this type allows 32 bit systems to do native
  math without helper functions from libgcc.
* _alpm_pkghash_create() now internally adds extra padding for
  additional array elements, rather than that being the responsibility of
  the caller.
* #define values are moved into static const values in pkghash.c; a new
  `stride` value is also extracted (but remains set at 1).
* Division and modulus operators are removed from the normal find and
  add paths if possible. We store the upper limit of the number of
  elements in the hash so we no longer need to calculate this every
  element addition. When doing wraparound position calculations, we only
  apply the modulus operator if the value is greater than the number of
  buckets.

Signed-off-by: Dan McGee <dan@archlinux.org>
lib/libalpm/be_local.c
lib/libalpm/be_sync.c
lib/libalpm/pkghash.c
lib/libalpm/pkghash.h