From 9478e96bb98bb1a932997fb4ad1571ddb43ba04e Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Mon, 14 Sep 2026 21:10:36 -0700 Subject: [PATCH] perf: skip NFD normalization for ASCII paths --- src/tagstudio/core/utils/normalization.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tagstudio/core/utils/normalization.py b/src/tagstudio/core/utils/normalization.py index 3ba17230..eec71353 100644 --- a/src/tagstudio/core/utils/normalization.py +++ b/src/tagstudio/core/utils/normalization.py @@ -10,7 +10,10 @@ def norm_path(path: Path | str, case_sensitive: bool) -> Path: """Return `path` normalized to Unicode Normalization Form D (NFD).""" if isinstance(path, str): path = Path(path) - normalized = unicodedata.normalize("NFD", path.as_posix()) + posix = path.as_posix() + # NOTE: ASCII paths will be unaffected by all unicode normalization and can be skipped. + # See: https://unicode.org/reports/tr15/ + normalized = posix if posix.isascii() else unicodedata.normalize("NFD", posix) if not case_sensitive: normalized = normalized.casefold() return Path(normalized)