diff mercurial/context.py @ 52723:a502f3f389b5

context: use a single lookup for a cache hit This is just a small obvious cleanup opportunity.
author Rapha?l Gom?s <rgomes@octobus.net>
date Sun, 02 Feb 2025 00:20:11 +0100
parents f071b18e1382
children b3349f6cded9
line wrap: on
line diff
--- a/mercurial/context.py	Sat Feb 01 13:47:56 2025 +0100
+++ b/mercurial/context.py	Sun Feb 02 00:20:11 2025 +0100
@@ -2542,17 +2542,18 @@
         files = self.files()
 
         def getfile(repo, memctx, path):
-            if path not in self._cache:
+            hit = self._cache.get(path)
+            if hit is None:
                 return self.filectx(path)
-            elif self._cache[path][b'exists']:
+            elif hit[b'exists']:
                 return memfilectx(
                     repo,
                     memctx,
                     path,
-                    self._cache[path][b'data'],
-                    b'l' in self._cache[path][b'flags'],
-                    b'x' in self._cache[path][b'flags'],
-                    self._cache[path][b'copied'],
+                    hit[b'data'],
+                    b'l' in hit[b'flags'],
+                    b'x' in hit[b'flags'],
+                    hit[b'copied'],
                 )
             else:
                 # Returning None, but including the path in `files`, is