1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00
Commit Graph

11 Commits

Author SHA1 Message Date
Dan McGee
d1cc1ef6c3 Fix some database size estimation problems
* Use stat() and not lstat(); we don't care for the size of the symlink if
  it is one, we want the size of the reference file.
* FS#22896, fix local database estimation on platforms that don't abide by
  the nlink assumption for number of children.
* Fix a missing newline on an error message.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-15 16:58:08 -06:00
Pang Yan Han
da3b934602 Refactor out common code in pkghash add functions
The overlapping code in _alpm_pkghash_add() and _alpm_pkghash_add_sorted()
are now in a new static function pkghash_add_pkg(). This function has a
third flag parameter which determines whether the package should be added in
sorted order.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-07 20:26:11 -06:00
Dan McGee
6b0d4674bb Improve pkghash_remove algorithm
Rather than potentially move every item to the next NULL, attempt to move at
most one item at a time by iterating backwards from the NULL location in the
hash array. If we move an item, we repeat the process on the now shorter
"chain" until no more items need moving.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 10:03:04 +10:00
Dan McGee
1f145bcd1a Use alpm_list_remove_item in pkghash_remove
Removes the code that was duplicated and has now been refactored into a
separate method.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:55:46 +10:00
Allan McRae
01c3c7e4f2 Actually remove packages from pkghash on removal
Fully removes a package from the hash.  Also unify prototype with
removal from an alpm_list_t, fixing issues when removing a package
from the pkgcache.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae
11e5e86151 Refactor finding position for new hash entry
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae
9320786349 Rehash efficiently
Rehash without recreating the hash table list or reallocating the
memory for holding the list nodes.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae
c9820ec97b Slightly more efficient rehash size selection
While probably still not optimal in terms of everyday usage in
pacman, this reduces the absolute size increase to "more reasonable"
levels.  For databases greater than 5000 in size, the minimum size
increase is used which is still on the order of a 10% increase.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae
d843c86b7b Error handling for maximum database size
Check that the requested size of a pkghash is not beyond the maximum
prime.  Also check for successful creation of a new hash before
rehashing.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Dan McGee
ce54715112 Implement a quick and dirty rehash function
This allows us to get through the rehash required by smoke001 and pass
all pactests. It is by no means the best or most efficient
implementation but it does do the job.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:55:45 +10:00
Allan McRae
e17b0446bd Add a hash table for holding packages
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00