deepcopy is really slow and unnecessary here
authorJacob Lifshay <programmerjake@gmail.com>
Wed, 14 Jun 2023 05:56:10 +0000 (22:56 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 22 Dec 2023 19:26:19 +0000 (19:26 +0000)
src/openpower/test/state.py

index 99b6a175966da8042dd7965a0e027e8b19a60751..b2eb250ad9a4ce90e192e646fae748f91a89094c 100644 (file)
@@ -446,19 +446,34 @@ class ExpectedState(State):
             fp_regs = 32
         if isinstance(fp_regs, int):
             fp_regs = [0] * fp_regs
-        self.fpregs = deepcopy(fp_regs)
+        else:
+            assert isinstance(fp_regs, list), \
+                "fp_regs must be int | list[int] | None"
+            # don't use deepcopy, it's slow
+            fp_regs = fp_regs.copy()
+        self.fpregs = fp_regs
         self.fpscr = fpscr
         if int_regs is None:
             int_regs = 32
         if isinstance(int_regs, int):
             int_regs = [0] * int_regs
-        self.intregs = deepcopy(int_regs)
+        else:
+            assert isinstance(int_regs, list), \
+                "int_regs must be int | list[int] | None"
+            # don't use deepcopy, it's slow
+            int_regs = int_regs.copy()
+        self.intregs = int_regs
         self.pc = pc
         if crregs is None:
             crregs = 8
         if isinstance(crregs, int):
             crregs = [0] * crregs
-        self.crregs = deepcopy(crregs)
+        else:
+            assert isinstance(crregs, list), \
+                "crregs must be int | list[int] | None"
+            # don't use deepcopy, it's slow
+            crregs = crregs.copy()
+        self.crregs = crregs
         self.so = so
         self.ov = ov
         self.ca = ca