summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-08-17 23:25:19 -0500
committerDan McGee <dan@archlinux.org>2011-08-18 10:47:41 -0500
commitc4bd476ad13e142fe8323fe74d84b3950b53da17 (patch)
treeddfd2afb08bf94b300eecee7cfef3394ed8c1092 /lib
parentc885a953eb888004f0302ed3eceafef93e2f072f (diff)
downloadpacman-c4bd476ad13e142fe8323fe74d84b3950b53da17.tar.xz
Remove use of no-op accessor functions in library
The functions alpm_db_get_name(), alpm_pkg_get_name(), and alpm_pkg_get_version() are not necessary at all, so remove the calling and indirection when used in the backend, which makes things slightly more efficient and reduces code size. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/add.c34
-rw-r--r--lib/libalpm/be_local.c5
-rw-r--r--lib/libalpm/conflict.c5
-rw-r--r--lib/libalpm/db.c8
-rw-r--r--lib/libalpm/package.c5
-rw-r--r--lib/libalpm/remove.c6
-rw-r--r--lib/libalpm/sync.c13
-rw-r--r--lib/libalpm/trans.c4
8 files changed, 36 insertions, 44 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 5e1bb8da..8bbf1574 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -76,8 +76,8 @@ int SYMEXPORT alpm_add_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
local = _alpm_db_get_pkgfromcache(handle->db_local, pkgname);
if(local) {
- const char *localpkgname = alpm_pkg_get_name(local);
- const char *localpkgver = alpm_pkg_get_version(local);
+ const char *localpkgname = local->name;
+ const char *localpkgver = local->version;
int cmp = _alpm_pkg_compare_versions(pkg, local);
if(cmp == 0) {
@@ -460,8 +460,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
ASSERT(trans != NULL, return -1);
snprintf(scriptlet, PATH_MAX, "%s%s-%s/install",
- _alpm_db_path(db), alpm_pkg_get_name(newpkg),
- alpm_pkg_get_version(newpkg));
+ _alpm_db_path(db), newpkg->name, newpkg->version);
/* see if this is an upgrade. if so, remove the old package first */
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(db, newpkg->name);
@@ -517,7 +516,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
changelog/install script installation (FS#12263) */
if(_alpm_local_db_prepare(db, newpkg)) {
alpm_logaction(handle, "error: could not create database entry %s-%s\n",
- alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
+ newpkg->name, newpkg->version);
handle->pm_errno = ALPM_ERR_DB_WRITE;
ret = -1;
goto cleanup;
@@ -566,10 +565,10 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* call PROGRESS once with 0 percent, as we sort-of skip that here */
if(is_upgrade) {
PROGRESS(trans, ALPM_TRANS_PROGRESS_UPGRADE_START,
- alpm_pkg_get_name(newpkg), 0, pkg_count, pkg_current);
+ newpkg->name, 0, pkg_count, pkg_current);
} else {
PROGRESS(trans, ALPM_TRANS_PROGRESS_ADD_START,
- alpm_pkg_get_name(newpkg), 0, pkg_count, pkg_current);
+ newpkg->name, 0, pkg_count, pkg_current);
}
for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
@@ -593,12 +592,10 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
if(is_upgrade) {
PROGRESS(trans, ALPM_TRANS_PROGRESS_UPGRADE_START,
- alpm_pkg_get_name(newpkg), percent, pkg_count,
- pkg_current);
+ newpkg->name, percent, pkg_count, pkg_current);
} else {
PROGRESS(trans, ALPM_TRANS_PROGRESS_ADD_START,
- alpm_pkg_get_name(newpkg), percent, pkg_count,
- pkg_current);
+ newpkg->name, percent, pkg_count, pkg_current);
}
/* extract the next file from the archive */
@@ -635,9 +632,9 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
if(_alpm_local_db_write(db, newpkg, INFRQ_ALL)) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not update database entry %s-%s\n"),
- alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
+ newpkg->name, newpkg->version);
alpm_logaction(handle, "error: could not update database entry %s-%s\n",
- alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
+ newpkg->name, newpkg->version);
handle->pm_errno = ALPM_ERR_DB_WRITE;
ret = -1;
goto cleanup;
@@ -645,15 +642,15 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
if(_alpm_db_add_pkgincache(db, newpkg) == -1) {
_alpm_log(handle, ALPM_LOG_ERROR, _("could not add entry '%s' in cache\n"),
- alpm_pkg_get_name(newpkg));
+ newpkg->name);
}
if(is_upgrade) {
PROGRESS(trans, ALPM_TRANS_PROGRESS_UPGRADE_START,
- alpm_pkg_get_name(newpkg), 100, pkg_count, pkg_current);
+ newpkg->name, 100, pkg_count, pkg_current);
} else {
PROGRESS(trans, ALPM_TRANS_PROGRESS_ADD_START,
- alpm_pkg_get_name(newpkg), 100, pkg_count, pkg_current);
+ newpkg->name, 100, pkg_count, pkg_current);
}
/* run the post-install script if it exists */
@@ -661,11 +658,10 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
&& !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
if(is_upgrade) {
_alpm_runscriptlet(handle, scriptlet, "post_upgrade",
- alpm_pkg_get_version(newpkg),
- oldpkg ? alpm_pkg_get_version(oldpkg) : NULL);
+ newpkg->version, oldpkg ? oldpkg->version : NULL);
} else {
_alpm_runscriptlet(handle, scriptlet, "post_install",
- alpm_pkg_get_version(newpkg), NULL);
+ newpkg->version, NULL);
}
}
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 5b69f628..1b489224 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -192,11 +192,10 @@ static alpm_list_t *_cache_get_backup(alpm_pkg_t *pkg)
static void *_cache_changelog_open(alpm_pkg_t *pkg)
{
char clfile[PATH_MAX];
+ alpm_db_t *db = alpm_pkg_get_db(pkg);
snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog",
alpm_option_get_dbpath(pkg->handle),
- alpm_db_get_name(alpm_pkg_get_db(pkg)),
- alpm_pkg_get_name(pkg),
- alpm_pkg_get_version(pkg));
+ db->treename, pkg->name, pkg->version);
return fopen(clfile, "r");
}
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index fe182094..5d279536 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -409,7 +409,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
numtargs, current);
/* CHECK 1: check every target against every target */
_alpm_log(handle, ALPM_LOG_DEBUG, "searching for file conflicts: %s\n",
- alpm_pkg_get_name(p1));
+ p1->name);
for(j = i->next; j; j = j->next) {
alpm_list_t *common_files;
alpm_pkg_t *p2 = j->data;
@@ -422,8 +422,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
for(k = common_files; k; k = k->next) {
snprintf(path, PATH_MAX, "%s%s", handle->root, (char *)k->data);
conflicts = add_fileconflict(handle, conflicts,
- ALPM_FILECONFLICT_TARGET, path,
- alpm_pkg_get_name(p1), alpm_pkg_get_name(p2));
+ ALPM_FILECONFLICT_TARGET, path, p1->name, p2->name);
if(handle->pm_errno == ALPM_ERR_MEMORY) {
FREELIST(conflicts);
FREELIST(common_files);
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 8a235e21..77bdf98c 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -411,7 +411,7 @@ alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles)
for(j = list; j; j = j->next) {
alpm_pkg_t *pkg = j->data;
const char *matched = NULL;
- const char *name = alpm_pkg_get_name(pkg);
+ const char *name = pkg->name;
const char *desc = alpm_pkg_get_desc(pkg);
/* check name as regex AND as plain text */
@@ -559,7 +559,7 @@ int _alpm_db_add_pkgincache(alpm_db_t *db, alpm_pkg_t *pkg)
}
_alpm_log(db->handle, ALPM_LOG_DEBUG, "adding entry '%s' in '%s' cache\n",
- alpm_pkg_get_name(newpkg), db->treename);
+ newpkg->name, db->treename);
db->pkgcache = _alpm_pkghash_add_sorted(db->pkgcache, newpkg);
free_groupcache(db);
@@ -576,13 +576,13 @@ int _alpm_db_remove_pkgfromcache(alpm_db_t *db, alpm_pkg_t *pkg)
}
_alpm_log(db->handle, ALPM_LOG_DEBUG, "removing entry '%s' from '%s' cache\n",
- alpm_pkg_get_name(pkg), db->treename);
+ pkg->name, db->treename);
db->pkgcache = _alpm_pkghash_remove(db->pkgcache, pkg, &data);
if(data == NULL) {
/* package not found */
_alpm_log(db->handle, ALPM_LOG_DEBUG, "cannot remove entry '%s' from '%s' cache: not found\n",
- alpm_pkg_get_name(pkg), db->treename);
+ pkg->name, db->treename);
return -1;
}
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index a88af5e2..a31effbc 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -618,8 +618,7 @@ void _alpm_pkg_free_trans(alpm_pkg_t *pkg)
/* Is spkg an upgrade for localpkg? */
int _alpm_pkg_compare_versions(alpm_pkg_t *spkg, alpm_pkg_t *localpkg)
{
- return alpm_pkg_vercmp(alpm_pkg_get_version(spkg),
- alpm_pkg_get_version(localpkg));
+ return alpm_pkg_vercmp(spkg->version, localpkg->version);
}
/* Helper function for comparing packages
@@ -677,7 +676,7 @@ int _alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg)
alpm_list_t *groups = NULL;
/* first see if the package is ignored */
- if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) {
+ if(alpm_list_find_str(handle->ignorepkg, pkg->name)) {
return 1;
}
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 0afa2656..c6886c6f 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -81,9 +81,9 @@ static void remove_prepare_cascade(alpm_handle_t *handle, alpm_list_t *lp)
alpm_depmissing_t *miss = i->data;
alpm_pkg_t *info = _alpm_db_get_pkgfromcache(handle->db_local, miss->target);
if(info) {
- if(!_alpm_pkg_find(trans->remove, alpm_pkg_get_name(info))) {
+ if(!_alpm_pkg_find(trans->remove, info->name)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "pulling %s in target list\n",
- alpm_pkg_get_name(info));
+ info->name);
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(info));
}
} else {
@@ -117,7 +117,7 @@ static void remove_prepare_keep_needed(alpm_handle_t *handle, alpm_list_t *lp)
pkg = vpkg;
if(pkg) {
_alpm_log(handle, ALPM_LOG_WARNING, _("removing %s from target list\n"),
- alpm_pkg_get_name(pkg));
+ pkg->name);
_alpm_pkg_free(pkg);
}
}
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index a5964b9d..b9cb1fbe 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -62,20 +62,19 @@ alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_syn
pkg->handle->pm_errno = 0;
for(i = dbs_sync; !spkg && i; i = i->next) {
- spkg = _alpm_db_get_pkgfromcache(i->data, alpm_pkg_get_name(pkg));
+ spkg = _alpm_db_get_pkgfromcache(i->data, pkg->name);
}
if(spkg == NULL) {
_alpm_log(pkg->handle, ALPM_LOG_DEBUG, "'%s' not found in sync db => no upgrade\n",
- alpm_pkg_get_name(pkg));
+ pkg->name);
return NULL;
}
/* compare versions and see if spkg is an upgrade */
if(_alpm_pkg_compare_versions(spkg, pkg) > 0) {
_alpm_log(pkg->handle, ALPM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n",
- alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg),
- alpm_pkg_get_version(spkg));
+ pkg->name, pkg->version, spkg->version);
return spkg;
}
/* spkg is not an upgrade */
@@ -229,7 +228,7 @@ alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs,
for(j = grp->packages; j; j = j->next) {
alpm_pkg_t *pkg = j->data;
- if(_alpm_pkg_find(ignorelist, alpm_pkg_get_name(pkg))) {
+ if(_alpm_pkg_find(ignorelist, pkg->name)) {
continue;
}
if(_alpm_pkg_should_ignore(db->handle, pkg)) {
@@ -240,7 +239,7 @@ alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs,
if(!install)
continue;
}
- if(!_alpm_pkg_find(pkgs, alpm_pkg_get_name(pkg))) {
+ if(!_alpm_pkg_find(pkgs, pkg->name)) {
pkgs = alpm_list_add(pkgs, pkg);
}
}
@@ -296,7 +295,7 @@ static int compute_download_size(alpm_pkg_t *newpkg)
}
_alpm_log(handle, ALPM_LOG_DEBUG, "setting download size %jd for pkg %s\n",
- (intmax_t)size, alpm_pkg_get_name(newpkg));
+ (intmax_t)size, newpkg->name);
newpkg->infolevel |= INFRQ_DSIZE;
newpkg->download_size = size;
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 1bab830d..3f595960 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -91,8 +91,8 @@ static alpm_list_t *check_arch(alpm_handle_t *handle, alpm_list_t *pkgs)
const char *pkgarch = alpm_pkg_get_arch(pkg);
if(pkgarch && strcmp(pkgarch, arch) && strcmp(pkgarch, "any")) {
char *string;
- const char *pkgname = alpm_pkg_get_name(pkg);
- const char *pkgver = alpm_pkg_get_version(pkg);
+ const char *pkgname = pkg->name;
+ const char *pkgver = pkg->version;
size_t len = strlen(pkgname) + strlen(pkgver) + strlen(pkgarch) + 3;
MALLOC(string, len, RET_ERR(handle, ALPM_ERR_MEMORY, invalid));
sprintf(string, "%s-%s-%s", pkgname, pkgver, pkgarch);