# HG changeset patch # User Franz Glasner # Date 1639737767 -3600 # Node ID 1de6cc49776e80893d49bf3448a646ee9ab5c31f # Parent eddc0f7c6271f886985a043cceaabbe2bd4fb219 Optimize .unquote() by aliasing some methods to locals and avoiding the first append call diff -r eddc0f7c6271 -r 1de6cc49776e configmix/config.py --- 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)