commit:     9ef4e24ba6ff64bb1addb3112ebdf3b3e58bdb07
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 30 10:47:55 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Dec 31 13:33:04 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9ef4e24b

checksum: Consider C implementation of Whirlpool accelerated

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/checksum.py       |  9 ++++++---
 lib/portage/util/whirlpool.py | 13 -------------
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py
index f23897d91..3bdb2bc53 100644
--- a/lib/portage/checksum.py
+++ b/lib/portage/checksum.py
@@ -310,10 +310,13 @@ if "STREEBOG256" not in hashfunc_map or "STREEBOG512" not 
in hashfunc_map:
 _whirlpool_unaccelerated = False
 if "WHIRLPOOL" not in hashfunc_map:
     # Bundled WHIRLPOOL implementation
-    _whirlpool_unaccelerated = True
-    from portage.util.whirlpool import new as _new_whirlpool
+    from portage.util.whirlpool import CWhirlpool, PyWhirlpool
 
-    _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
+    if CWhirlpool.is_available:
+        _generate_hash_function("WHIRLPOOL", CWhirlpool, origin="bundled-c")
+    else:
+        _whirlpool_unaccelerated = True
+        _generate_hash_function("WHIRLPOOL", PyWhirlpool, origin="bundled-py")
 
 
 # There is only one implementation for size

diff --git a/lib/portage/util/whirlpool.py b/lib/portage/util/whirlpool.py
index 7caa20f6e..8454a874a 100644
--- a/lib/portage/util/whirlpool.py
+++ b/lib/portage/util/whirlpool.py
@@ -110,19 +110,6 @@ class CWhirlpool:
         return tempstr
 
 
-if WhirlpoolExt is not None:
-    Whirlpool = CWhirlpool
-else:
-    Whirlpool = PyWhirlpool
-
-
-def new(init=b""):
-    """Return a new Whirlpool object. An optional string argument
-    may be provided; if present, this string will be automatically
-    hashed."""
-    return Whirlpool(init)
-
-
 #
 # Private.
 #

Reply via email to