branch: elpa/git-commit commit 8842230bcafae287e56a8a4597aaa4539c3345d6 Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
Use length= and length> These functions potentially improve performance, though honestly their use probably does not make a measurable difference in most of these cases. Still a good idea to get into the habit of using them. --- lisp/magit-apply.el | 4 ++-- lisp/magit-base.el | 6 +++--- lisp/magit-branch.el | 6 +++--- lisp/magit-clone.el | 2 +- lisp/magit-diff.el | 2 +- lisp/magit-ediff.el | 2 +- lisp/magit-git.el | 8 ++++---- lisp/magit-log.el | 4 ++-- lisp/magit-remote.el | 4 ++-- lisp/magit-repos.el | 2 +- lisp/magit-worktree.el | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lisp/magit-apply.el b/lisp/magit-apply.el index 52db7c0463..8230c2d4a0 100644 --- a/lisp/magit-apply.el +++ b/lisp/magit-apply.el @@ -655,7 +655,7 @@ of a side, then keep that side without prompting." (setq sections (--remove (member (oref it value) binaries) sections))) - (cond ((= (length sections) 1) + (cond ((length= sections 1) (magit-discard-apply (car sections) 'magit-apply-diff)) (sections (magit-discard-apply-n sections #'magit-apply-diffs))) @@ -718,7 +718,7 @@ so causes the change to be applied to the index as well." (--separate (member (oref it value) bs) sections)))) (magit-confirm-files 'reverse (--map (oref it value) sections)) - (cond ((= (length sections) 1) + (cond ((length= sections 1) (magit-reverse-apply (car sections) #'magit-apply-diff args)) (sections (magit-reverse-apply sections #'magit-apply-diffs args))) diff --git a/lisp/magit-base.el b/lisp/magit-base.el index a9866f5b84..4bbf76f8ef 100644 --- a/lisp/magit-base.el +++ b/lisp/magit-base.el @@ -715,7 +715,7 @@ back to built-in `completing-read' for now." :error) initial-input hist def))) (defun magit-prompt-with-default (prompt def) - (if (and def (> (length prompt) 2) + (if (and def (length> prompt 2) (string-equal ": " (substring prompt -2))) (format "%s (default %s): " (substring prompt 0 -2) def) prompt)) @@ -824,9 +824,9 @@ ACTION is a member of option `magit-slow-confirm'." (or (not sitems) items)) ((not sitems) (magit-y-or-n-p prompt action)) - ((= (length items) 1) + ((length= items 1) (and (magit-y-or-n-p prompt action) items)) - ((> (length items) 1) + ((length> items 1) (and (magit-y-or-n-p (concat (mapconcat #'identity items "\n") "\n\n" prompt-n) action) diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el index 80f52bb2c8..cf62d17ace 100644 --- a/lisp/magit-branch.el +++ b/lisp/magit-branch.el @@ -554,7 +554,7 @@ defaulting to the branch at point." (interactive (let ((branches (magit-region-values 'branch t)) (force current-prefix-arg)) - (if (> (length branches) 1) + (if (length> branches 1) (magit-confirm t nil "Delete %i branches" nil branches) (setq branches (list (magit-read-branch-prefer-other @@ -612,7 +612,7 @@ defaulting to the branch at point." (magit-rev-parse "--short" ref)) (magit-call-git "update-ref" "-d" ref)) (magit-refresh))))) - ((> (length branches) 1) + ((length> branches 1) (setq branches (delete (magit-get-current-branch) branches)) (mapc #'magit-branch-maybe-delete-pr-remote branches) (mapc #'magit-branch-unset-pushRemote branches) @@ -673,7 +673,7 @@ defaulting to the branch at point." (format "+refs/heads/%s:refs/remotes/%s/%s" merge remote merge)))))) (when (member refspec refspecs) - (if (and (= (length refspecs) 1) + (if (and (length= refspecs 1) (magit-confirm 'delete-pr-remote (format "Also delete remote %s (%s)" remote "no pull-request branch remains") diff --git a/lisp/magit-clone.el b/lisp/magit-clone.el index b332978957..fb5c893282 100644 --- a/lisp/magit-clone.el +++ b/lisp/magit-clone.el @@ -233,7 +233,7 @@ Then show the status buffer for the new repository." (setq directory (file-name-as-directory (expand-file-name directory))) (when (file-exists-p directory) (if (file-directory-p directory) - (when (> (length (directory-files directory)) 2) + (when (length> (directory-files directory) 2) (let ((name (magit-clone--url-to-name repository))) (unless (and name (setq directory (file-name-as-directory diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el index 1141973675..c27b8a5250 100644 --- a/lisp/magit-diff.el +++ b/lisp/magit-diff.el @@ -2435,7 +2435,7 @@ section or a child thereof." (split-string (substring str 1) ","))) (split-string (match-string 1)))) (about (match-string 2)) - (combined (= (length ranges) 3)) + (combined (length= ranges 3)) (value (cons about ranges))) (magit-delete-line) (magit-insert-section section (hunk value) diff --git a/lisp/magit-ediff.el b/lisp/magit-ediff.el index 437a874bf6..0012c2cd04 100644 --- a/lisp/magit-ediff.el +++ b/lisp/magit-ediff.el @@ -159,7 +159,7 @@ conflicts, including those already resolved by Git, use (defmacro magit-ediff-buffers (quit &rest spec) (declare (indent 1)) - (let ((fn (if (= (length spec) 3) 'ediff-buffers3 'ediff-buffers)) + (let ((fn (if (length= spec 3) 'ediff-buffers3 'ediff-buffers)) (char ?@) get make kill) (pcase-dolist (`(,g ,m) spec) diff --git a/lisp/magit-git.el b/lisp/magit-git.el index d5b8d8aa6c..2232173817 100644 --- a/lisp/magit-git.el +++ b/lisp/magit-git.el @@ -1199,7 +1199,7 @@ Sorted from longest to shortest CYGWIN name." (defun magit-merge-commit-p (commit) "Return t if COMMIT is a merge commit." - (> (length (magit-commit-parents commit)) 1)) + (length> (magit-commit-parents commit) 1)) (defun magit-anything-staged-p (&optional ignore-submodules &rest files) "Return t if there are any staged changes. @@ -1648,7 +1648,7 @@ according to the branch type." (defun magit-get-current-remote (&optional allow-unnamed) (or (magit-get-upstream-remote nil allow-unnamed) (and-let* ((remotes (magit-list-remotes)) - (remote (if (= (length remotes) 1) + (remote (if (length= remotes 1) (car remotes) (magit-primary-remote)))) (magit--propertize-face remote 'magit-branch-remote)))) @@ -2580,7 +2580,7 @@ out. Only existing branches can be selected." (defun magit-read-remote (prompt &optional default use-only) (let ((remotes (magit-list-remotes))) - (if (and use-only (= (length remotes) 1)) + (if (and use-only (length= remotes 1)) (car remotes) (magit-completing-read prompt remotes nil t nil nil @@ -2619,7 +2619,7 @@ out. Only existing branches can be selected." (setq modules (-filter predicate modules))) (unless modules (user-error "No modules satisfying %s selected" predicate)))) - (if (> (length modules) 1) + (if (length> modules 1) (magit-confirm t nil (format "%s %%i modules" verb) nil modules) (list (magit-read-module-path (format "%s module" verb) predicate))))) diff --git a/lisp/magit-log.el b/lisp/magit-log.el index 88ddec7424..659f202355 100644 --- a/lisp/magit-log.el +++ b/lisp/magit-log.el @@ -1051,7 +1051,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. (files magit-buffer-log-files)) (magit-set-header-line-format (funcall magit-log-header-line-function revs args files)) - (unless (= (length files) 1) + (unless (length= files 1) (setq args (remove "--follow" args))) (when (and (car magit-log-remove-graph-args) (--any-p (string-match-p @@ -1062,7 +1062,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. (setq args (remove "--color" args))) (when-let* ((limit (magit-log-get-commit-limit)) (limit (* 2 limit)) ; increase odds for complete graph - (count (and (= (length revs) 1) + (count (and (length= revs 1) (> limit 1024) ; otherwise it's fast enough (setq revs (car revs)) (not (string-search ".." revs)) diff --git a/lisp/magit-remote.el b/lisp/magit-remote.el index 2665be7115..38efe2e45e 100644 --- a/lisp/magit-remote.el +++ b/lisp/magit-remote.el @@ -205,7 +205,7 @@ the now stale refspecs. Other stale branches are not removed." (magit-call-git "remote" "rm" remote)) (?a "or [a]abort" (user-error "Abort"))) - (if (if (= (length stale) 1) + (if (if (length= stale 1) (pcase-let ((`(,refspec . ,refs) (car stale))) (magit-confirm 'prune-stale-refspecs (format "Prune stale refspec %s and branch %%s" refspec) @@ -268,7 +268,7 @@ refspec." (magit-read-remote "Delete remote")))) (let ((refspecs (magit-get-all "remote" remote "fetch")) (standard (format "+refs/heads/*:refs/remotes/%s/*" remote))) - (when (and (= (length refspecs) 1) + (when (and (length= refspecs 1) (not (string-search "*" (car refspecs))) (yes-or-no-p (format "Also replace refspec %s with %s? " (car refspecs) diff --git a/lisp/magit-repos.el b/lisp/magit-repos.el index 3432dc1c6f..954d3fd8e2 100644 --- a/lisp/magit-repos.el +++ b/lisp/magit-repos.el @@ -521,7 +521,7 @@ instead." (puthash (car a) (cons (cdr a) (gethash (car a) dict)) dict)) (maphash (lambda (key value) - (if (= (length value) 1) + (if (length= value 1) (push (cons key (car value)) result) (setq result (append result diff --git a/lisp/magit-worktree.el b/lisp/magit-worktree.el index a86b0ddd7c..fcfad85311 100644 --- a/lisp/magit-worktree.el +++ b/lisp/magit-worktree.el @@ -161,7 +161,7 @@ then show it in Dired instead." "Insert sections for all worktrees. If there is only one worktree, then insert nothing." (let ((worktrees (magit-list-worktrees))) - (when (> (length worktrees) 1) + (when (length> worktrees 1) (magit-insert-section (worktrees) (magit-insert-heading "Worktrees:") (let* ((cols