Mercurial > hgrepos > Python > libs > ConfigMix
changeset 477:1de6cc49776e
Optimize .unquote() by aliasing some methods to locals and avoiding the first append call
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Fri, 17 Dec 2021 11:42:47 +0100 |
| parents | eddc0f7c6271 |
| children | ff8a9a7c6a93 |
| files | configmix/config.py |
| diffstat | 1 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/configmix/config.py Fri Dec 17 11:09:14 2021 +0100 +++ b/configmix/config.py Fri Dec 17 11:42:47 2021 +0100 @@ -736,25 +736,25 @@ """ if klass._QUOTE not in s: return s - res = [] parts = s.split(klass._QUOTE) - res.append(parts[0]) + res = [parts[0]] + res_append = res.append for p in parts[1:]: if p.startswith(u(b'x')): if len(p) < 3: raise ValueError("quote syntax: length too small") - res.append(uchr(int(p[1:3], 16))) - res.append(p[3:]) + res_append(uchr(int(p[1:3], 16))) + res_append(p[3:]) elif p.startswith(u(b'u')): if len(p) < 5: raise ValueError("quote syntax: length too small") - res.append(uchr(int(p[1:5], 16))) - res.append(p[5:]) + res_append(uchr(int(p[1:5], 16))) + res_append(p[5:]) elif p.startswith(u(b'U')): if len(p) < 9: raise ValueError("quote syntax: length too small") - res.append(uchr(int(p[1:9], 16))) - res.append(p[9:]) + res_append(uchr(int(p[1:9], 16))) + res_append(p[9:]) else: raise ValueError("unknown quote syntax string: {}".format(s)) return ''.join(res)
