From 414a0b26e10bf2a8c021fd2b3c42fea9afd94beb Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 17 Feb 2025 19:33:56 +0100 Subject: [PATCH] Prefer '(oddp A)' to '(= 1 (logand A 1))' * 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 | 2 +- lisp/play/hanoi.el | 2 +- lisp/progmodes/ebnf2ps.el | 2 +- lisp/progmodes/elisp-mode.el | 2 +- lisp/progmodes/ruby-mode.el | 3 +-- lisp/ps-print.el | 10 ++++------ 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el index 328b474f0eb..1be77e2c9a9 100644 --- a/lisp/play/gamegrid.el +++ b/lisp/play/gamegrid.el @@ -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) diff --git a/lisp/play/hanoi.el b/lisp/play/hanoi.el index 1a4b6dbeb11..8bc8d77108b 100644 --- a/lisp/play/hanoi.el +++ b/lisp/play/hanoi.el @@ -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))) diff --git a/lisp/progmodes/ebnf2ps.el b/lisp/progmodes/ebnf2ps.el index f3b2d8bb4a4..0147707f80d 100644 --- a/lisp/progmodes/ebnf2ps.el +++ b/lisp/progmodes/ebnf2ps.el @@ -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)))) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index f4d444b9982..22279744841 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -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)))))) diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 77a3eb8b325..3e56479ed51 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -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))) diff --git a/lisp/ps-print.el b/lisp/ps-print.el index 0908eeb7b50..ba0d543bbcc 100644 --- a/lisp/ps-print.el +++ b/lisp/ps-print.el @@ -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) -- 2.39.5