1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-05 11:21:04 -08:00

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.
This commit is contained in:
Stefan Kangas 2025-02-17 19:33:56 +01:00
parent 7c7cf3e8c8
commit fd5dbea21b
10 changed files with 13 additions and 16 deletions

View file

@ -3752,7 +3752,7 @@ The placement of the padding is determined by the value of user
option `todo-categories-align'." option `todo-categories-align'."
(let* ((len (todo-adjusted-category-label-length)) (let* ((len (todo-adjusted-category-label-length))
(strlen (length str)) (strlen (length str))
(strlen-odd (eq (logand strlen 1) 1)) (strlen-odd (oddp strlen))
(padding (max 0 (/ (- len strlen) 2))) (padding (max 0 (/ (- len strlen) 2)))
(padding-left (cond ((eq todo-categories-align 'left) 0) (padding-left (cond ((eq todo-categories-align 'left) 0)
((eq todo-categories-align 'center) padding) ((eq todo-categories-align 'center) padding)

View file

@ -294,7 +294,7 @@ The return value is the last VAL in the list.
\(fn PLACE VAL PLACE VAL ...)" \(fn PLACE VAL PLACE VAL ...)"
(declare (debug (&rest [gv-place form]))) (declare (debug (&rest [gv-place form])))
(if (/= (logand (length args) 1) 0) (if (oddp (length args))
(signal 'wrong-number-of-arguments (list 'setf (length args)))) (signal 'wrong-number-of-arguments (list 'setf (length args))))
(if (and args (null (cddr args))) (if (and args (null (cddr args)))
(let ((place (pop args)) (let ((place (pop args))

View file

@ -435,7 +435,7 @@ Assumes the caller has bound `macroexpand-all-environment'."
;; Malformed code is translated to code that signals an error ;; Malformed code is translated to code that signals an error
;; at run time. ;; at run time.
(let ((nargs (length args))) (let ((nargs (length args)))
(if (/= (logand nargs 1) 0) (if (oddp nargs)
(macroexp-warn-and-return (macroexp-warn-and-return
(format-message "odd number of arguments in `setq' form") (format-message "odd number of arguments in `setq' form")
`(signal 'wrong-number-of-arguments '(setq ,nargs)) `(signal 'wrong-number-of-arguments '(setq ,nargs))

View file

@ -1011,7 +1011,7 @@ Embedded whitespace, dashes, and periods in the string are ignored."
(let ((chars '())) (let ((chars '()))
(let ((len (length str)) (let ((len (length str))
(idx 0)) (idx 0))
(if (eq (logand len 1) 1) (if (oddp len)
(let ((num (hexl-hex-string-to-integer (substring str 0 1)))) (let ((num (hexl-hex-string-to-integer (substring str 0 1))))
(setq chars (cons num chars)) (setq chars (cons num chars))
(setq idx 1))) (setq idx 1)))

View file

@ -205,7 +205,7 @@ static unsigned char gamegrid_bits[] = {
(make-list (/ center-pixel-count 2) "01") (make-list (/ center-pixel-count 2) "01")
(list right-border))))) (list right-border)))))
(dotimes (row center-pixel-count) (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"))) (insert ", \n")))
(dotimes (row border-pixel-count) (dotimes (row border-pixel-count)

View file

@ -266,7 +266,7 @@ BITS must be of length nrings. Start at START-TIME."
(make-string (1- radius) (if vert ?\- ?\|)) (make-string (1- radius) (if vert ?\- ?\|))
(if vert ">" "v")) (if vert ">" "v"))
for face = 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) hanoi-odd-ring-face hanoi-even-ring-face)
do (hanoi-put-face 0 (length str) face str) do (hanoi-put-face 0 (length str) face str)
collect (cons str diameter))) collect (cons str diameter)))

View file

@ -5947,7 +5947,7 @@ killed after process termination."
(defun ebnf-end-of-string () (defun ebnf-end-of-string ()
(let ((n 1)) (let ((n 1))
(while (> (logand n 1) 0) (while (oddp n)
(skip-chars-forward "^\"" ebnf-limit) (skip-chars-forward "^\"" ebnf-limit)
(setq n (- (skip-chars-backward "\\\\"))) (setq n (- (skip-chars-backward "\\\\")))
(goto-char (+ (point) n 1)))) (goto-char (+ (point) n 1))))

View file

@ -2008,7 +2008,7 @@ ARGS is the argument list of function SYM."
(and (string-match-p "\\.\\.\\.\\'" (and (string-match-p "\\.\\.\\.\\'"
(substring args 1 (1- (length args)))) (substring args 1 (1- (length args))))
(= (length (remove "..." args-lst)) 2) (= (length (remove "..." args-lst)) 2)
(> index 1) (eq (logand index 1) 1))) (> index 1) (oddp index)))
(setq index 0)) (setq index 0))
(t (t
(setq index (1- index)))))) (setq index (1- index))))))

View file

@ -1816,8 +1816,7 @@ With ARG, do it many times. Negative ARG means move forward."
((looking-at "\\s\"\\|\\\\\\S_") ((looking-at "\\s\"\\|\\\\\\S_")
(let ((c (char-to-string (char-before (match-end 0))))) (let ((c (char-to-string (char-before (match-end 0)))))
(while (and (search-backward c) (while (and (search-backward c)
(eq (logand (skip-chars-backward "\\\\") 1) (oddp (skip-chars-backward "\\\\")))))
1))))
nil) nil)
((looking-at "\\s.\\|\\s\\") ((looking-at "\\s.\\|\\s\\")
(if (ruby-special-char-p) (forward-char -1))) (if (ruby-special-char-p) (forward-char -1)))

View 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) (cond ((eq ps-even-or-odd-pages 'even-page)
(evenp ps-page-postscript)) (evenp ps-page-postscript))
((eq ps-even-or-odd-pages 'odd-page) ((eq ps-even-or-odd-pages 'odd-page)
(= (logand ps-page-postscript 1) 1)) (oddp ps-page-postscript))
(t) (t)))))
))))
(defsubst ps-print-sheet-p () (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) (cond ((eq ps-even-or-odd-pages 'even-sheet)
(evenp ps-page-sheet)) (evenp ps-page-sheet))
((eq ps-even-or-odd-pages 'odd-sheet) ((eq ps-even-or-odd-pages 'odd-sheet)
(= (logand ps-page-sheet 1) 1)) (oddp ps-page-sheet))
(t) (t))))
)))
(defun ps-output (&rest args) (defun ps-output (&rest args)