From eb5cb8ec02bf31b4a5e84ea38c196dae67bf2aac Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 2 Jan 2012 12:52:00 -0600 Subject: Remove unnecessary counters in file removal code Now that filelist arrays know their own size, we don't need to do the bookkeeping we used to do when they were linked lists. Remove some of the counter variables and use math instead. Signed-off-by: Dan McGee --- lib/libalpm/remove.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/libalpm/remove.c') diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index b43d1a62..f5c3c078 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -360,7 +360,7 @@ static int remove_package_files(alpm_handle_t *handle, { alpm_list_t *skip_remove; alpm_filelist_t *filelist; - size_t i, filenum = 0, position = 0; + size_t i; int err = 0; int nosave = handle->trans->flags & ALPM_TRANS_FLAG_NOSAVE; @@ -398,10 +398,9 @@ static int remove_package_files(alpm_handle_t *handle, FREELIST(skip_remove); RET_ERR(handle, ALPM_ERR_PKG_CANT_REMOVE, -1); } - filenum++; } - _alpm_log(handle, ALPM_LOG_DEBUG, "removing %zd files\n", filenum); + _alpm_log(handle, ALPM_LOG_DEBUG, "removing %zd files\n", filelist->count); if(!newpkg) { /* init progress bar, but only on true remove transactions */ @@ -418,11 +417,10 @@ static int remove_package_files(alpm_handle_t *handle, if(!newpkg) { /* update progress bar after each file */ - int percent = (position * 100) / filenum; + int percent = ((filelist->count - i) * 100) / filelist->count; PROGRESS(handle, ALPM_PROGRESS_REMOVE_START, oldpkg->name, percent, pkg_count, targ_count); } - position++; } FREELIST(skip_remove); -- cgit v1.2.3-24-g4f1b