From ba0ddffb14756c3fc87d51d1c78f71d4a09c7cb1 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 13 Jun 2023 22:55:49 -0700 Subject: [PATCH] speed up StateSPRs.__init__ --- src/openpower/test/state.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openpower/test/state.py b/src/openpower/test/state.py index 5d61c277..99b6a175 100644 --- a/src/openpower/test/state.py +++ b/src/openpower/test/state.py @@ -66,9 +66,13 @@ class StateRunner: class StateSPRs: KEYS = tuple(i for i in SPRfull if i != SPRfull.XER) + __EMPTY_VALUES = {k: 0 for k in KEYS} def __init__(self, values=None): - self.__values = {k: 0 for k in StateSPRs.KEYS} + if isinstance(values, StateSPRs): + self.__values = values.__values.copy() + return + self.__values = self.__EMPTY_VALUES.copy() if values is not None: for k, v in values.items(): self[k] = v -- 2.30.2