# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2016-08-12 22:51:42 # Node ID 997e8cf4d0a29d28759e38659736cb3d1cf9ef3f # Parent 594035c1adc7fa4c176564a96b62fe2d367bf7b6 pycompat: avoid using an extra function We have a single line function which just lowercase the letters and replaces "_" with "". Its better to avoid that function call. Moreover we calling this function around 33 times. diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -41,11 +41,10 @@ def _alias(alias, origin, items): copies items from origin to alias """ - def hgcase(item): - return item.replace('_', '').lower() for item in items: try: - setattr(alias, hgcase(item), getattr(origin, item)) + lcase = item.replace('_', '').lower() + setattr(alias, lcase, getattr(origin, item)) except AttributeError: pass