diff --git a/src/caelestia/utils/dots/source.py b/src/caelestia/utils/dots/source.py index f5023bb..d2c7159 100644 --- a/src/caelestia/utils/dots/source.py +++ b/src/caelestia/utils/dots/source.py @@ -17,6 +17,8 @@ class DotsSource: cfg = get_config().get("dots", {}) self.url = cfg.get("url", "https://github.com/caelestia-dots/caelestia.git") self.branch = cfg.get("branch", "main") + # Cache git blobs by (ref, relpath); objects are immutable for a given rev + self._blob_cache: dict[tuple[str, str], bytes] = {} @property def remote_ref(self) -> str: @@ -90,7 +92,10 @@ class DotsSource: return self._git("show", f"{ref}:{relpath}") def blob_at(self, ref: str, relpath: str) -> bytes: - return self._git_bytes("show", f"{ref}:{relpath}") + key = (ref, relpath) + if key not in self._blob_cache: + self._blob_cache[key] = self._git_bytes("show", f"{ref}:{relpath}") + return self._blob_cache[key] def files_at(self, ref: str, relpath: str) -> list[str]: """Repo-relative paths of all files under relpath at ref (the path itself if it is a file)."""