[Yum-devel] [PATCH 3/5] Eliminate linear search for names in callback

seth vidal skvidal at fedoraproject.org
Thu Feb 24 16:10:14 UTC 2011


On Thu, 2011-02-24 at 11:18 +0200, Panu Matilainen wrote:
> We only care if the name has been seen so a dict works for the
> purpose just as well and is faster.
> ---
>  yum/rpmtrans.py |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
> index 30c9dd3..cf06e0f 100644
> --- a/yum/rpmtrans.py
> +++ b/yum/rpmtrans.py
> @@ -178,7 +178,7 @@ class RPMTransaction:
>          self.total_actions = 0
>          self.total_installed = 0
>          self.complete_actions = 0
> -        self.installed_pkg_names = []
> +        self.installed_pkg_names = {}
>          self.total_removed = 0
>          self.logger = logging.getLogger('yum.filelogging.RPMInstallCallback')
>          self.filelog = False
> @@ -426,7 +426,7 @@ class RPMTransaction:
>                  if self.trans_running:
>                      self.total_installed += 1
>                      self.complete_actions += 1
> -                    self.installed_pkg_names.append(hdr['name'])
> +                    self.installed_pkg_names[hdr['name']] = None
>                  return self.fd.fileno()
>          else:
>              self.display.errorlog("Error: No Header to INST_OPEN_FILE")


ACK, the 'not in' case works the same.

-sv




More information about the Yum-devel mailing list