Skip to content

Commit

Permalink
Optimize canonicalize_filename
Browse files Browse the repository at this point in the history
Using str.split is faster than Path.parts
  • Loading branch information
bruchar1 committed Jan 29, 2025
1 parent fb435c0 commit 81e5d0f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mesonbuild/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,9 @@ def determine_rpath_dirs(self, target: T.Union[build.BuildTarget, build.CustomTa
@staticmethod
@lru_cache(maxsize=None)
def canonicalize_filename(fname: str) -> str:
parts = Path(fname).parts
if os.path.altsep is not None:
fname = fname.replace(os.path.altsep, os.path.sep)
parts = fname.split(os.path.sep)
hashed = ''
if len(parts) > 5:
temp = '/'.join(parts[-5:])
Expand Down

0 comments on commit 81e5d0f

Please sign in to comment.