changeset 47009:42eb8b7881b8 stable

repoview: style change in newtype() cache handling This way of writing it does not change the logic at all, but is more fit for the change we want to make in the next changeset. If anything, that's one dict lookup less in the hot path, but that should be non measurable.
author Georges Racinet <georges.racinet@octobus.net>
date Sat, 24 Apr 2021 15:46:39 +0200
parents 77e73827a02d
children 76ae43d5b1db
files mercurial/repoview.py
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/repoview.py	Thu Apr 22 02:57:30 2021 +0200
+++ b/mercurial/repoview.py	Sat Apr 24 15:46:39 2021 +0200
@@ -472,10 +472,12 @@
 
 def newtype(base):
     """Create a new type with the repoview mixin and the given base class"""
-    if base not in _filteredrepotypes:
+    cls = _filteredrepotypes.get(base)
+    if cls is not None:
+        return cls
 
-        class filteredrepo(repoview, base):
-            pass
+    class filteredrepo(repoview, base):
+        pass
 
-        _filteredrepotypes[base] = filteredrepo
-    return _filteredrepotypes[base]
+    _filteredrepotypes[base] = filteredrepo
+    return filteredrepo