Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65dc9be

Browse files
authored
Merge pull request #24699 from jpjepko/texcache-four-levels
Implement nested four-level TeX cache
2 parents b62376c + 631b286 commit 65dc9be

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/matplotlib/texmanager.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,15 @@ def get_basefile(cls, tex, fontsize, dpi=None):
176176
Return a filename based on a hash of the string, fontsize, and dpi.
177177
"""
178178
src = cls._get_tex_source(tex, fontsize) + str(dpi)
179-
return os.path.join(
180-
cls.texcache, hashlib.md5(src.encode('utf-8')).hexdigest())
179+
filehash = hashlib.md5(src.encode('utf-8')).hexdigest()
180+
filepath = Path(cls.texcache)
181+
182+
num_letters, num_levels = 2, 2
183+
for i in range(0, num_letters*num_levels, num_letters):
184+
filepath = filepath / Path(filehash[i:i+2])
185+
186+
filepath.mkdir(parents=True, exist_ok=True)
187+
return os.path.join(filepath, filehash)
181188

182189
@classmethod
183190
def get_font_preamble(cls):

0 commit comments

Comments
 (0)