[PATCH] keyword: prefer i in d over d.has_key(i)

TK Soh teekaysoh at gmail.com
Sun Jan 20 07:46:25 CST 2008


On Jan 20, 2008 1:40 PM, Christian Ebert <blacktrash at gmx.net> wrote:
> # HG changeset patch
> # User Christian Ebert <blacktrash at gmx.net>
> # Date 1200836365 -3600
> # Node ID acb07e704df612295f74d8792bfa07e44e88217f
> # Parent  d67cfe0d4714a28a448475d31a8a3ab22453f42a
> keyword: prefer i in d over d.has_key(i)
>
> diff --git a/hgext/keyword.py b/hgext/keyword.py
> --- a/hgext/keyword.py
> +++ b/hgext/keyword.py
> @@ -243,7 +243,7 @@
>      mf = ctx.manifest()
>      if node is not None:   # commit
>          _kwtemplater.commitnode = node
> -        files = [f for f in ctx.files() if mf.has_key(f)]
> +        files = [f for f in ctx.files() if f in mf]
>          notify = ui.debug
>      else:                  # kwexpand/kwshrink
>          notify = ui.note

Just curious. Is 'in' more efficient than haskey()?


More information about the Mercurial-devel mailing list