Patchwork [4,of,6] color: merge two identical 'for' loops

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 21, 2017, 10:18 p.m.
Message ID <1f69891d7e7abe1f3707.1487715480@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18698/
State Accepted
Headers show

Comments

Pierre-Yves David - Feb. 21, 2017, 10:18 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1487238747 -3600
#      Thu Feb 16 10:52:27 2017 +0100
# Node ID 1f69891d7e7abe1f3707c5f184498eadcd42dc6f
# Parent  7d0d86f63673633f2223f60a13d359a243cbb946
# EXP-Topic color
color: merge two identical 'for' loops

The previous changeset made it clear that we are iterating twice on the same
items. We gather the two loops into a single one.

Patch

diff -r 7d0d86f63673 -r 1f69891d7e7a hgext/color.py
--- a/hgext/color.py	Thu Dec 22 13:06:53 2016 +0100
+++ b/hgext/color.py	Thu Feb 16 10:52:27 2017 +0100
@@ -206,9 +206,7 @@  def _terminfosetup(ui, mode):
         if key.startswith('color.'):
             newval = (False, int(val), '')
             color._terminfo_params[key[6:]] = newval
-
-    for key, val in ui.configitems('color'):
-        if key.startswith('terminfo.'):
+        elif key.startswith('terminfo.'):
             newval = (True, '', val.replace('\\E', '\x1b'))
             color._terminfo_params[key[9:]] = newval
     try: