Skip to content

Commit

Permalink
perf: Use mapcar instead of cl-mapcar
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jun 15, 2024
1 parent a1dffa3 commit 6cf05e5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
14 changes: 7 additions & 7 deletions centaur-tabs-elements.el
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive."

(defun centaur-tabs-separator-reverse-pattern (pattern)
"Reverse each line in PATTERN."
(cl-mapcar 'reverse pattern))
(mapcar 'reverse pattern))

(defun centaur-tabs-separator-row-pattern (fill total &optional fade)
"Make a list that has FILL 0s out of TOTAL 1s with FADE 2s to the right of
Expand All @@ -529,11 +529,11 @@ and `body' arguments,respectively. HEIGHT-EXP is an expression
calculating the image height and it should contain a free variable `height'.
PATTERN-HEIGHT-SYM and SECOND-PATTERN-HEIGHT-SYM are symbols used
for let-var binding variables."
(let* ((pattern (centaur-tabs-separator-pattern (cl-mapcar 'centaur-tabs-separator-pattern-to-string (car patterns))))
(header (cl-mapcar 'centaur-tabs-separator-pattern-to-string (nth 1 patterns)))
(footer (cl-mapcar 'centaur-tabs-separator-pattern-to-string (nth 2 patterns)))
(second-pattern (centaur-tabs-separator-pattern (cl-mapcar 'centaur-tabs-separator-pattern-to-string (nth 3 patterns))))
(center (cl-mapcar 'centaur-tabs-separator-pattern-to-string (nth 4 patterns)))
(let* ((pattern (centaur-tabs-separator-pattern (mapcar 'centaur-tabs-separator-pattern-to-string (car patterns))))
(header (mapcar 'centaur-tabs-separator-pattern-to-string (nth 1 patterns)))
(footer (mapcar 'centaur-tabs-separator-pattern-to-string (nth 2 patterns)))
(second-pattern (centaur-tabs-separator-pattern (mapcar 'centaur-tabs-separator-pattern-to-string (nth 3 patterns))))
(center (mapcar 'centaur-tabs-separator-pattern-to-string (nth 4 patterns)))
(reserve (+ (length header) (length footer) (length center))))
(when pattern
(cons `((,pattern-height-sym (max (- ,height-exp ,reserve) 0))
Expand Down Expand Up @@ -578,7 +578,7 @@ PATTERN, HEADER, FOOTER, SECOND-PATTERN, CENTER are of the form
COLOR can be one of 0, 1, or 2, where 0 is the source color, 1 is the
destination color, and 2 is the interpolated color between 0 and 1."
(when (eq dir 'right)
(setq patterns (cl-mapcar 'centaur-tabs-separator-reverse-pattern patterns)))
(setq patterns (mapcar 'centaur-tabs-separator-reverse-pattern patterns)))
(let ((bindings-body (centaur-tabs-separator-pattern-bindings-body patterns
'height
'pattern-height
Expand Down
44 changes: 22 additions & 22 deletions centaur-tabs-functions.el
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ The result is a list just as long as the number of existing tab sets."
"Make a new tab set whose name is the string NAME.
It is initialized with tabs build from the list of OBJECTS."
(let* ((tabset (intern name centaur-tabs-tabsets))
(tabs (cl-mapcar #'(lambda (object)
(centaur-tabs-make-tab object tabset))
objects)))
(tabs (mapcar #'(lambda (object)
(centaur-tabs-make-tab object tabset))
objects)))
(set tabset tabs)
(centaur-tabs-put-cache tabset 'select (car tabs))
(put tabset 'start 0)
Expand All @@ -382,7 +382,7 @@ That is, remove it from the tab sets store."

(defsubst centaur-tabs-tab-values (tabset)
"Return the list of tab values in TABSET."
(cl-mapcar 'centaur-tabs-tab-value (centaur-tabs-tabs tabset)))
(mapcar 'centaur-tabs-tab-value (centaur-tabs-tabs tabset)))

(defun centaur-tabs-get-cache (cache key)
"Return the per-frame cached value of KEY in CACHE."
Expand Down Expand Up @@ -467,7 +467,7 @@ Otherwise insert it."
tabs
(let* ((tab (centaur-tabs-make-tab object tabset))
(selected (centaur-tabs-selected-tab tabset))
(selected-index (cl-position (car selected) (cl-mapcar 'car tabs))))
(selected-index (cl-position (car selected) (mapcar 'car tabs))))
(centaur-tabs-set-template tabset nil)
(set tabset (centaur-tabs-insert-at tabs selected-index tab))))))

Expand Down Expand Up @@ -787,7 +787,7 @@ template element."
(padcolor centaur-tabs-background-color)
(all-tabs (centaur-tabs-tabs tabset))
(total-tabs (length all-tabs))
(sel-index (+ (cl-position (car sel) (cl-mapcar 'car all-tabs)) 1))
(sel-index (+ (cl-position (car sel) (mapcar 'car all-tabs)) 1))
atsel elts)
;; Track the selected tab to ensure it is always visible.
(when centaur-tabs--track-selected
Expand Down Expand Up @@ -995,7 +995,7 @@ Depend on the setting of the option `centaur-tabs-cycle-scope'."
(defun centaur-tabs-filter-out (condp lst)
"Filter list LST with using CONDP as the filtering condition."
(delq nil
(cl-mapcar (lambda (x) (if (funcall condp x) nil x)) lst)))
(mapcar (lambda (x) (if (funcall condp x) nil x)) lst)))

(defun centaur-tabs-buffer-list ()
"Return the list of buffers to show in tabs.
Expand All @@ -1004,14 +1004,14 @@ visiting a file. The current buffer is always included."
(centaur-tabs-filter-out
'centaur-tabs-hide-tab-cached
(delq nil
(cl-mapcar #'(lambda (b)
(cond
;; Always include the current buffer.
((eq (current-buffer) b) b)
((buffer-file-name b) b)
((char-equal ?\ (aref (buffer-name b) 0)) nil)
((buffer-live-p b) b)))
(buffer-list)))))
(mapcar #'(lambda (b)
(cond
;; Always include the current buffer.
((eq (current-buffer) b) b)
((buffer-file-name b) b)
((char-equal ?\ (aref (buffer-name b) 0)) nil)
((buffer-live-p b) b)))
(buffer-list)))))

(defun centaur-tabs-buffer-mode-derived-p (mode parents)
"Return non-nil if MODE derives from a mode in PARENTS."
Expand All @@ -1031,7 +1031,7 @@ visiting a file. The current buffer is always included."
"Update tabsets from groups of existing buffers.
Return the the first group where the current buffer is."
(let ((bl (sort
(cl-mapcar
(mapcar
#'(lambda (b)
(with-current-buffer b
(list (current-buffer)
Expand Down Expand Up @@ -1065,8 +1065,8 @@ Return the the first group where the current buffer is."
(dolist (tab (centaur-tabs-tabs tabset))
(let ((e (assq (centaur-tabs-tab-value tab) bl)))
(or (and e (memq tabset
(cl-mapcar 'centaur-tabs-get-tabset
(nth 2 e))))
(mapcar 'centaur-tabs-get-tabset
(nth 2 e))))
(centaur-tabs-delete-tab tab))))
;; Return empty tab sets
(unless (centaur-tabs-tabs tabset)
Expand Down Expand Up @@ -1196,7 +1196,7 @@ buffer changed."
(when (string= current-group centaur-tabs-last-focused-buffer-group)
(let* ((bufset (centaur-tabs-get-tabset current-group))
(current-group-tabs (centaur-tabs-tabs bufset))
(current-group-buffers (cl-mapcar 'car current-group-tabs))
(current-group-buffers (mapcar 'car current-group-tabs))
(current-buffer-index (cl-position current current-group-buffers))
(previous-buffer-index (cl-position previous current-group-buffers)))

Expand Down Expand Up @@ -1364,9 +1364,9 @@ Operates over buffer BUF"
(defun centaur-tabs-get-groups ()
"Refresh tabs groups."
(set centaur-tabs-tabsets-tabset (centaur-tabs-map-tabsets 'centaur-tabs-selected-tab))
(cl-mapcar #'(lambda (group)
(format "%s" (cdr group)))
(centaur-tabs-tabs centaur-tabs-tabsets-tabset)))
(mapcar #'(lambda (group)
(format "%s" (cdr group)))
(centaur-tabs-tabs centaur-tabs-tabsets-tabset)))

(defun centaur-tabs-get-extensions ()
"Get file extension of tabs."
Expand Down
2 changes: 1 addition & 1 deletion centaur-tabs-interactive.el
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
(defun centaur-tabs-switch-group (&optional groupname)
"Switch tab groups using ido. GROUPNAME can optionaly be provided."
(interactive)
(let* ((tab-buffer-list (cl-mapcar
(let* ((tab-buffer-list (mapcar
#'(lambda (b)
(with-current-buffer b
(list (current-buffer)
Expand Down

0 comments on commit 6cf05e5

Please sign in to comment.