Mercurial > hg
diff mercurial/registrar.py @ 38829:7e7e2b2ff284
fileset: add stub for weight-based optimization
The main purpose of this change is to group basic patterns, which can be
mapped to a plain matcher. I'm not so interested in a weight of each function.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 21 Jul 2018 15:52:26 +0900 |
parents | 5d9749c598f0 |
children | bfd5def3fe02 |
line wrap: on
line diff
--- a/mercurial/registrar.py Sat Jul 21 16:16:44 2018 +0900 +++ b/mercurial/registrar.py Sat Jul 21 15:52:26 2018 +0900 @@ -247,6 +247,9 @@ implies 'matchctx.status()' at runtime or not (False, by default). + Optional argument 'weight' indicates the estimated run-time cost, useful + for static optimization, default is 1. Higher weight means more expensive. + 'filesetpredicate' instance in example above can be used to decorate multiple functions. @@ -259,8 +262,9 @@ _getname = _funcregistrarbase._parsefuncdecl _docformat = "``%s``\n %s" - def _extrasetup(self, name, func, callstatus=False): + def _extrasetup(self, name, func, callstatus=False, weight=1): func._callstatus = callstatus + func._weight = weight class _templateregistrarbase(_funcregistrarbase): """Base of decorator to register functions as template specific one