From 60e7c1baeffad3a1267e97bb824623ea92d4071e 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