diff --git a/ircstates/casemap.py b/ircstates/casemap.py index 3fa1621..0782453 100644 --- a/ircstates/casemap.py +++ b/ircstates/casemap.py @@ -1,5 +1,6 @@ import string from typing import List +from cachetools import cached, LRUCache ASCII_UPPER = list(string.ascii_uppercase) ASCII_LOWER = list(string.ascii_lowercase) @@ -15,6 +16,7 @@ def _replace(s: str, upper: List[str], lower: List[str]): out += char return out +@cached(cache=LRUCache(maxsize=1024)) def casefold(mapping: str, s: str): if mapping == "rfc1459": return _replace(s, RFC1459_UPPER, RFC1459_LOWER) diff --git a/requirements.txt b/requirements.txt index dee6d8a..cc9c163 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ -freezegun ~=1.1.0 -irctokens ~=2.0.0 -pendulum ~=2.1.0 +cachetools ~=5.0.0 +freezegun ~=1.1.0 +irctokens ~=2.0.0 +pendulum ~=2.1.0