mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-10 21:38:19 -05:00
Remove three unnecessary usages of alpm_list_count()
For the files count when loading from a package, we can keep a counter. The two in the frontend were completely useless due to the fact that if sync_dbs is non-NULL, alpm_list_count() will always be greater than 0. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
d589a7b5db
commit
f12ead2cf2
@ -241,6 +241,7 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
|
|||||||
struct archive_entry *entry;
|
struct archive_entry *entry;
|
||||||
pmpkg_t *newpkg = NULL;
|
pmpkg_t *newpkg = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
size_t files_count = 0;
|
||||||
|
|
||||||
if(pkgfile == NULL || strlen(pkgfile) == 0) {
|
if(pkgfile == NULL || strlen(pkgfile) == 0) {
|
||||||
RET_ERR(handle, PM_ERR_WRONG_ARGS, NULL);
|
RET_ERR(handle, PM_ERR_WRONG_ARGS, NULL);
|
||||||
@ -328,6 +329,7 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
|
|||||||
} else if(full) {
|
} else if(full) {
|
||||||
/* Keep track of all files for filelist generation */
|
/* Keep track of all files for filelist generation */
|
||||||
newpkg->files = alpm_list_add(newpkg->files, strdup(entry_name));
|
newpkg->files = alpm_list_add(newpkg->files, strdup(entry_name));
|
||||||
|
files_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(archive_read_data_skip(archive)) {
|
if(archive_read_data_skip(archive)) {
|
||||||
@ -366,8 +368,7 @@ pmpkg_t *_alpm_pkg_load_internal(pmhandle_t *handle, const char *pkgfile,
|
|||||||
if(full) {
|
if(full) {
|
||||||
/* "checking for conflicts" requires a sorted list, ensure that here */
|
/* "checking for conflicts" requires a sorted list, ensure that here */
|
||||||
_alpm_log(handle, PM_LOG_DEBUG, "sorting package filelist for %s\n", pkgfile);
|
_alpm_log(handle, PM_LOG_DEBUG, "sorting package filelist for %s\n", pkgfile);
|
||||||
newpkg->files = alpm_list_msort(newpkg->files, alpm_list_count(newpkg->files),
|
newpkg->files = alpm_list_msort(newpkg->files, files_count, _alpm_str_cmp);
|
||||||
_alpm_str_cmp);
|
|
||||||
newpkg->infolevel = INFRQ_ALL;
|
newpkg->infolevel = INFRQ_ALL;
|
||||||
} else {
|
} else {
|
||||||
/* get rid of any partial filelist we may have collected, it is invalid */
|
/* get rid of any partial filelist we may have collected, it is invalid */
|
||||||
|
@ -502,7 +502,7 @@ int pacman_query(alpm_list_t *targets)
|
|||||||
if(config->op_q_foreign) {
|
if(config->op_q_foreign) {
|
||||||
/* ensure we have at least one valid sync db set up */
|
/* ensure we have at least one valid sync db set up */
|
||||||
alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
|
alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle);
|
||||||
if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
|
if(sync_dbs == NULL) {
|
||||||
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
|
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -911,7 +911,7 @@ int pacman_sync(alpm_list_t *targets)
|
|||||||
|
|
||||||
/* ensure we have at least one valid sync db set up */
|
/* ensure we have at least one valid sync db set up */
|
||||||
sync_dbs = alpm_option_get_syncdbs(config->handle);
|
sync_dbs = alpm_option_get_syncdbs(config->handle);
|
||||||
if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
|
if(sync_dbs == NULL) {
|
||||||
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
|
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user