Skip to content

Commit

Permalink
Merge pull request #24699 from jpjepko/texcache-four-levels
Browse files Browse the repository at this point in the history
Implement nested four-level TeX cache
  • Loading branch information
QuLogic committed Dec 22, 2022
2 parents b62376c + 631b286 commit 65dc9be
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/matplotlib/texmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,15 @@ def get_basefile(cls, tex, fontsize, dpi=None):
Return a filename based on a hash of the string, fontsize, and dpi.
"""
src = cls._get_tex_source(tex, fontsize) + str(dpi)
return os.path.join(
cls.texcache, hashlib.md5(src.encode('utf-8')).hexdigest())
filehash = hashlib.md5(src.encode('utf-8')).hexdigest()
filepath = Path(cls.texcache)

num_letters, num_levels = 2, 2
for i in range(0, num_letters*num_levels, num_letters):
filepath = filepath / Path(filehash[i:i+2])

filepath.mkdir(parents=True, exist_ok=True)
return os.path.join(filepath, filehash)

@classmethod
def get_font_preamble(cls):
Expand Down

0 comments on commit 65dc9be

Please sign in to comment.