Skip to content

Commit

Permalink
wrap: Cache get_releases()
Browse files Browse the repository at this point in the history
"meson wrap status" was calling it for each .wrap file. Better use
lru_cache to ensure we don't make the same mistake elsewhere.
  • Loading branch information
xclaesse committed Nov 10, 2023
1 parent b24a73e commit 0dc9367
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mesonbuild/wrap/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from base64 import b64encode
from netrc import netrc
from pathlib import Path, PurePath
from functools import lru_cache

from . import WrapMode
from .. import coredata
Expand Down Expand Up @@ -111,6 +112,7 @@ def get_releases_data(allow_insecure: bool) -> bytes:
url = open_wrapdburl('https://wrapdb.mesonbuild.com/v2/releases.json', allow_insecure, True)
return url.read()

@lru_cache(maxsize=None)
def get_releases(allow_insecure: bool) -> T.Dict[str, T.Any]:
data = get_releases_data(allow_insecure)
return T.cast('T.Dict[str, T.Any]', json.loads(data.decode()))
Expand Down

0 comments on commit 0dc9367

Please sign in to comment.