Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/pycompat.py @ 29790:997e8cf4d0a2
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.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 13 Aug 2016 04:21:42 +0530 |
parents | 594035c1adc7 |
children | 965c91bad9e3 |
comparison
equal
deleted
inserted
replaced
29789:594035c1adc7 | 29790:997e8cf4d0a2 |
---|---|
39 def _alias(alias, origin, items): | 39 def _alias(alias, origin, items): |
40 """ populate a _pycompatstub | 40 """ populate a _pycompatstub |
41 | 41 |
42 copies items from origin to alias | 42 copies items from origin to alias |
43 """ | 43 """ |
44 def hgcase(item): | |
45 return item.replace('_', '').lower() | |
46 for item in items: | 44 for item in items: |
47 try: | 45 try: |
48 setattr(alias, hgcase(item), getattr(origin, item)) | 46 lcase = item.replace('_', '').lower() |
47 setattr(alias, lcase, getattr(origin, item)) | |
49 except AttributeError: | 48 except AttributeError: |
50 pass | 49 pass |
51 | 50 |
52 httpserver = _pycompatstub() | 51 httpserver = _pycompatstub() |
53 urlreq = _pycompatstub() | 52 urlreq = _pycompatstub() |