emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] feature/gnus-select e3bcd11 160/218: Port data-tests-popcn


From: Andrew G Cohen
Subject: [Emacs-diffs] feature/gnus-select e3bcd11 160/218: Port data-tests-popcnt to 32-bit Emacs
Date: Fri, 14 Dec 2018 03:35:21 -0500 (EST)

branch: feature/gnus-select
commit e3bcd115d2ac7d9574cf94635f109e326a08d70a
Author: Paul Eggert <address@hidden>
Commit: Andrew G Cohen <address@hidden>

    Port data-tests-popcnt to 32-bit Emacs
    
    * test/src/data-tests.el (data-tests-popcnt):
    Don’t assume Emacs integers can represent 32-bit quantities.
    Change to a simple and straightforward approach, since runtime
    performance is not important here.
---
 test/src/data-tests.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index 3b88dbc..33b00d6 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -111,9 +111,9 @@
   "Calculate the Hamming weight of BYTE."
   (if (< byte 0)
       (setq byte (lognot byte)))
-  (setq byte (- byte (logand (lsh byte -1) #x55555555)))
-  (setq byte (+ (logand byte #x33333333) (logand (lsh byte -2) #x33333333)))
-  (lsh (* (logand (+ byte (lsh byte -4)) #x0f0f0f0f) #x01010101) -24))
+  (if (zerop byte)
+      0
+    (+ (logand byte 1) (data-tests-popcnt (lsh byte -1)))))
 
 (ert-deftest data-tests-logcount ()
   (should (cl-loop for n in (number-sequence -255 255)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]