xbps_transaction_*: multiple performance improvements (v2).
This commit implements multiple performance improvements to the transaction code: - Don't process xbps_pkg_name() N times each time we access its package dictionary (via pkgdb or rpool), just do it once at xbps_pkgdb_init() time. At pkgdb init time, it just creates a property in pkgdb, "pkgname". At rpool time, each time a package is accessed, the "pkgname" string property is added. - The package transaction dictionary contains the "transaction" object to know what's the pkg type. This has been changed to an uint8, this simplifies the logic and it's faster than checking a string object. See xbps_trans_type_t and xbps_transaction_pkg_type(). - Fixed the issue that was marked with XXX in transaction shlibs checking code. This has been fixed and improved and resources are now just freed as expected. - Simplified random code all over the place, avoiding unnecessary allocations or operations. - Rename some transaction files to have a better description. This is my first rototill to the code in 2020.
This commit is contained in:
@ -76,6 +76,7 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
xbps_dictionary_t binpkg_propsd, binpkg_filesd, pkg_filesd, obsd;
|
||||
xbps_array_t array, obsoletes;
|
||||
xbps_data_t data;
|
||||
xbps_trans_type_t ttype;
|
||||
const struct stat *entry_statp;
|
||||
void *instbuf = NULL, *rembuf = NULL;
|
||||
struct stat st;
|
||||
@ -83,8 +84,8 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
struct archive_entry *entry;
|
||||
size_t instbufsiz = 0, rembufsiz = 0;
|
||||
ssize_t entry_size;
|
||||
const char *entry_pname, *transact, *binpkg_pkgver;
|
||||
char pkgname[XBPS_NAME_SIZE], *buf = NULL;
|
||||
const char *entry_pname, *binpkg_pkgver, *pkgname;
|
||||
char *buf = NULL;
|
||||
int ar_rv, rv, error, entry_type, flags;
|
||||
bool preserve, update, file_exists, keep_conf_file;
|
||||
bool skip_extract, force, xucd_stats;
|
||||
@ -96,21 +97,23 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
ar_rv = rv = error = entry_type = flags = 0;
|
||||
|
||||
xbps_dictionary_get_bool(pkg_repod, "preserve", &preserve);
|
||||
xbps_dictionary_get_cstring_nocopy(pkg_repod, "transaction", &transact);
|
||||
ttype = xbps_transaction_pkg_type(pkg_repod);
|
||||
|
||||
memset(&xucd, 0, sizeof(xucd));
|
||||
|
||||
euid = geteuid();
|
||||
|
||||
if (!xbps_pkg_name(pkgname, XBPS_NAME_SIZE, pkgver)) {
|
||||
abort();
|
||||
if (!xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgname", &pkgname)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (xhp->flags & XBPS_FLAG_FORCE_UNPACK)
|
||||
if (xhp->flags & XBPS_FLAG_FORCE_UNPACK) {
|
||||
force = true;
|
||||
}
|
||||
|
||||
if (strcmp(transact, "update") == 0)
|
||||
if (ttype == XBPS_TRANS_UPDATE) {
|
||||
update = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove obsolete files.
|
||||
|
Reference in New Issue
Block a user