Mercurial > hgrepos > Python > libs > ConfigMix
changeset 481:e3990ec55f2a
Use a quick-check for .quote() if no quoting is needed
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Fri, 17 Dec 2021 13:12:19 +0100 |
| parents | 3cfc808e613b |
| children | 8b8ffb74d452 |
| files | configmix/config.py |
| diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/configmix/config.py Fri Dec 17 12:49:07 2021 +0100 +++ b/configmix/config.py Fri Dec 17 13:12:19 2021 +0100 @@ -237,6 +237,13 @@ _QUOTE_u = u(b'u') _QUOTE_U = u(b'U') _COMMENT = u(b'#') + _QUOTE_SAFE = u(b'abcdefghijklmnopqrstuvwxyz' + b'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + b'0123456789' + b'-_@!§$&/()=?*+~;,<>´`^') + """Mostly used configuration key characters that do not need any quoting + + """ is_jail = False """Flag to show that this is not a jail for another configuration""" @@ -700,6 +707,10 @@ See also the :ref:`quoting` section. """ + # Quick check whether all of the chars is in _QUOTE_SAFE + if not s.rstrip(klass._QUOTE_SAFE): + return s + # Slow path qc = klass._QUOTE s = s.replace(qc, qc + "x25") s = s.replace(klass._DOT, qc + "x2e")
