Skip to content

Commit

Permalink
use functools cache to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonhc committed May 7, 2024
1 parent 827282a commit 4b6901c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fpdf/fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ def __len__(self):
def items(self):
for glyph, char_id in self._char_id_per_glyph.items():
yield glyph, char_id
@functools.lru_cache(maxsize=None)

@lru_cache(maxsize=None)
def pick(self, unicode: int):
glyph = self.get_glyph(unicode=unicode)
if glyph is None and unicode not in self.font.missing_glyphs:
Expand All @@ -482,7 +483,7 @@ def pick_glyph(self, glyph):
self._next += 1
return char_id

@functools.lru_cache(maxsize=None)
@lru_cache(maxsize=None)
def get_glyph(
self, glyph=None, unicode=None, glyph_name=None, glyph_width=None
) -> Glyph:
Expand Down

0 comments on commit 4b6901c

Please sign in to comment.