Prefer '(oddp A)' to '(= 1 (logand A 1))'
authorStefan Kangas <stefankangas@gmail.com>
Mon, 17 Feb 2025 18:33:56 +0000 (19:33 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 18 Feb 2025 08:53:49 +0000 (09:53 +0100)
* lisp/calendar/todo-mode.el (todo-padded-string):
* lisp/emacs-lisp/gv.el (setf):
* lisp/emacs-lisp/macroexp.el (macroexp--expand-all):
* lisp/hexl.el (hexl-insert-hex-string):
* lisp/play/gamegrid.el (gamegrid-xbm):
* lisp/play/hanoi.el (hanoi-internal):
* lisp/progmodes/ebnf2ps.el (ebnf-end-of-string):
* lisp/progmodes/elisp-mode.el (elisp--highlight-function-argument):
* lisp/progmodes/ruby-mode.el (ruby-backward-sexp):
* lisp/ps-print.el (ps-print-page-p):
(ps-print-sheet-p): Prefer '(oddp A)' to '(= 1 (logand A 1))' and
variations thereof.

(cherry picked from commit fd5dbea21b8982cff8d3ae774b0e68c077a4ec89)

lisp/play/gamegrid.el
lisp/play/hanoi.el
lisp/progmodes/ebnf2ps.el
lisp/progmodes/elisp-mode.el
lisp/progmodes/ruby-mode.el
lisp/ps-print.el

index 328b474f0ebb274dea1711d52a6e08bc4f6b34e9..1be77e2c9a900cfb0e224fc38dce268e7ddd369e 100644 (file)
@@ -205,7 +205,7 @@ static unsigned char gamegrid_bits[] = {
                                       (make-list (/ center-pixel-count 2) "01")
                                       (list right-border)))))
         (dotimes (row center-pixel-count)
-          (gamegrid-insert-xbm-bits (if (eq (logand row 1) 1) odd-line even-line))
+          (gamegrid-insert-xbm-bits (if (oddp row) odd-line even-line))
           (insert ", \n")))
 
       (dotimes (row border-pixel-count)
index 1a4b6dbeb114e178563d058a8eee8154c26b8c8a..8bc8d77108b74c526102ffa9d6b1147b77e45fe2 100644 (file)
@@ -266,7 +266,7 @@ BITS must be of length nrings.  Start at START-TIME."
                                  (make-string (1- radius) (if vert ?\- ?\|))
                                  (if vert ">" "v"))
                for face =
-               (if (eq (logand n 1) 1)  ; oddp would require cl at runtime
+               (if (oddp n)
                    hanoi-odd-ring-face hanoi-even-ring-face)
                do (hanoi-put-face 0 (length str) face str)
                collect (cons str diameter)))
index f3b2d8bb4a4549ab8361b0b6be8d5cb9b46088ff..0147707f80d1e4e37ddda5b530207c76aa4f6da7 100644 (file)
@@ -5947,7 +5947,7 @@ killed after process termination."
 
 (defun ebnf-end-of-string ()
   (let ((n 1))
-    (while (> (logand n 1) 0)
+    (while (oddp n)
       (skip-chars-forward "^\"" ebnf-limit)
       (setq n (- (skip-chars-backward "\\\\")))
       (goto-char (+ (point) n 1))))
index f4d444b9982cad0d44f16dda76ab970c76cac839..2227974484199ce9b9b39f124499f44f63212014 100644 (file)
@@ -2055,7 +2055,7 @@ ARGS is the argument list of function SYM."
                          (and (string-match-p "\\.\\.\\.\\'"
                                               (substring args 1 (1- (length args))))
                               (= (length (remove "..." args-lst)) 2)
-                              (> index 1) (eq (logand index 1) 1)))
+                              (> index 1) (oddp index)))
                      (setq index 0))
                    (t
                     (setq index (1- index))))))
index 77a3eb8b325891707e2417a6e694ef024a1ae111..3e56479ed51a88de5f9480fdc399c56f835da257 100644 (file)
@@ -1816,8 +1816,7 @@ With ARG, do it many times.  Negative ARG means move forward."
                   ((looking-at "\\s\"\\|\\\\\\S_")
                    (let ((c (char-to-string (char-before (match-end 0)))))
                      (while (and (search-backward c)
-                                (eq (logand (skip-chars-backward "\\\\") 1)
-                                    1))))
+                                (oddp (skip-chars-backward "\\\\")))))
                    nil)
                   ((looking-at "\\s.\\|\\s\\")
                    (if (ruby-special-char-p) (forward-char -1)))
index 0908eeb7b50ae7ede737e77d9967f1409b32f586..ba0d543bbcc82ee4648d0f7d4e44b9a9763ce416 100644 (file)
@@ -4607,9 +4607,8 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
             (cond ((eq ps-even-or-odd-pages 'even-page)
                    (evenp ps-page-postscript))
                   ((eq ps-even-or-odd-pages 'odd-page)
-                   (= (logand ps-page-postscript 1) 1))
-                  (t)
-                  ))))
+                   (oddp ps-page-postscript))
+                  (t)))))
 
 
 (defsubst ps-print-sheet-p ()
@@ -4617,9 +4616,8 @@ page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
        (cond ((eq ps-even-or-odd-pages 'even-sheet)
               (evenp ps-page-sheet))
              ((eq ps-even-or-odd-pages 'odd-sheet)
-              (= (logand ps-page-sheet 1) 1))
-             (t)
-             )))
+              (oddp ps-page-sheet))
+             (t))))
 
 
 (defun ps-output (&rest args)