Mercurial > public > mercurial-scm > hg-stable
diff mercurial/filesetlang.py @ 38902:61ab546b71c3
fileset: introduce weight constants for readability
These constants are defined in the filesetlang module since it's the
bottommost module depending on WEIGHT_CHECK_FILENAME, and extensions
will be likely to import it to process function arguments.
Credit for the naming goes to Augie Fackler.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 04 Aug 2018 17:08:33 +0900 |
parents | ca4de8ba5b5f |
children | 73731fa8d1bd |
line wrap: on
line diff
--- a/mercurial/filesetlang.py Sat Aug 04 17:17:31 2018 +0900 +++ b/mercurial/filesetlang.py Sat Aug 04 17:08:33 2018 +0900 @@ -14,6 +14,13 @@ pycompat, ) +# common weight constants for static optimization +# (see registrar.filesetpredicate for details) +WEIGHT_CHECK_FILENAME = 0.5 +WEIGHT_READ_CONTENTS = 30 +WEIGHT_STATUS = 10 +WEIGHT_STATUS_THOROUGH = 50 + elements = { # token-type: binding-strength, primary, prefix, infix, suffix "(": (20, None, ("group", 1, ")"), ("func", 1, ")"), None), @@ -184,7 +191,7 @@ op = x[0] if op in {'string', 'symbol'}: - return 0.5, x + return WEIGHT_CHECK_FILENAME, x if op == 'kindpat': w, t = _optimize(x[2]) return w, (op, x[1], t)