mirror of https://github.com/jesopo/ircstates
put a cachetools LRUCache on casefold()
This commit is contained in:
parent
1e187db35f
commit
e3884c7505
|
@ -1,5 +1,6 @@
|
||||||
import string
|
import string
|
||||||
from typing import List
|
from typing import List
|
||||||
|
from cachetools import cached, LRUCache
|
||||||
|
|
||||||
ASCII_UPPER = list(string.ascii_uppercase)
|
ASCII_UPPER = list(string.ascii_uppercase)
|
||||||
ASCII_LOWER = list(string.ascii_lowercase)
|
ASCII_LOWER = list(string.ascii_lowercase)
|
||||||
|
@ -15,6 +16,7 @@ def _replace(s: str, upper: List[str], lower: List[str]):
|
||||||
out += char
|
out += char
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
@cached(cache=LRUCache(maxsize=1024))
|
||||||
def casefold(mapping: str, s: str):
|
def casefold(mapping: str, s: str):
|
||||||
if mapping == "rfc1459":
|
if mapping == "rfc1459":
|
||||||
return _replace(s, RFC1459_UPPER, RFC1459_LOWER)
|
return _replace(s, RFC1459_UPPER, RFC1459_LOWER)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
freezegun ~=1.1.0
|
cachetools ~=5.0.0
|
||||||
irctokens ~=2.0.0
|
freezegun ~=1.1.0
|
||||||
pendulum ~=2.1.0
|
irctokens ~=2.0.0
|
||||||
|
pendulum ~=2.1.0
|
||||||
|
|
Loading…
Reference in New Issue