[PATCH] i18n: cache the result of every gettext call

Matt Mackall mpm at selenic.com
Fri Oct 17 17:30:14 CDT 2014


On Fri, 2014-10-17 at 18:21 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf at durin42.com>
> # Date 1413568330 14400
> #      Fri Oct 17 13:52:10 2014 -0400
> # Node ID b5ad46ae0e6a49525fb9d8268a61c517a271763e
> # Parent  149fc8a44184fbeddd9d9602e3860455e92c1301
> i18n: cache the result of every gettext call

Queued for default..

> +def _cachegettext(fn):
> +    cache = {}
> +    def inner(message):
> +        if message not in cache:
> +            cache[message] = fn(message)
> +        return cache[message]
> +    return inner

...without the dead code.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list