From f0c289495196e34851e4b18dbdcef08549c9f57a Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Sun, 14 Apr 2024 10:18:58 +0200 Subject: [PATCH] Remove side effect of digest on register state --- src/crc/_crc.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/crc/_crc.py b/src/crc/_crc.py index fb7a546..72c8779 100644 --- a/src/crc/_crc.py +++ b/src/crc/_crc.py @@ -253,9 +253,8 @@ def digest(self) -> int: """ See `AbstractRegister.digest` """ - if self._config.reverse_output: - self.register = self.reverse() - return self.register ^ self._config.final_xor_value + value = self.reverse() if self._config.reverse_output else self.register + return value ^ self._config.final_xor_value def reverse(self) -> int: """