The call stack result of profile-report doesn't match the real function codes

I'm trying to figure out why my emacs was slow tonight and found:

- command-execute                                               82796  87%
 - call-interactively                                           82792  87%
  - funcall-interactively                                       82792  87%
   - evil-ex-search-forward                                     42805  45%
    - apply                                                     42805  45%
     - #<compiled 0x1891b35>                                    42805  45%
      - apply                                                   42805  45%
       - #<compiled 0x17e0a1d>                                  42802  45%
        - evil-ex-start-search                                  42802  45%
         - read-string                                          42783  45%
          - redisplay_internal (C function)                     42587  45%
           - eval                                               42567  45%
            - awesome-tab-line                                  42557  45%
             - cond                                             42557  45%
              - or                                              42550  45%
               - awesome-tab-line-format                        42550  45%
                - let*                                          42544  45%
                 - while                                        42540  45%
                  - setq                                        42540  45%
                   - cons                                       42540  45%
                    - awesome-tab-line-tab                      42540  45%
                     - propertize                               42540  45%
                      - awesome-tab-buffer-tab-label              42540  45%
                       - let*                                   42540  45%
                        - concat                                42540  45%
                         - if                                   42522  45%
                          - awesome-tab-icon-for-tab              42522  45%
                           - if                                 42522  45%
                            - and                               42380  45%
                             - condition-case                   42374  45%
                                progn                           42374  45%
                            + progn                               142   0%

As the result shows, awesome-tab-icon-for-tab is the root cause. Here is the definition of awesome-tab-icon-for-tab:

(defun awesome-tab-icon-for-tab (tab face)
  "When tab buffer's file is exists, use `all-the-icons-icon-for-file' to fetch file icon.
Otherwise use `all-the-icons-icon-for-buffer' to fetch icon for buffer."
  (when (and awesome-tab-display-icon
             (ignore-errors (require 'all-the-icons)))
    (let* ((tab-buffer (car tab))
           (tab-file (buffer-file-name tab-buffer))
           (background (face-background face))
           (icon
            (cond
             ;; Use `all-the-icons-icon-for-file' if current file is exists.
             ((and
               tab-file
               (file-exists-p tab-file))
              (all-the-icons-icon-for-file tab-file :v-adjust awesome-tab-icon-v-adjust :height awesome-tab-icon-height))
             ;; Use `all-the-icons-icon-for-mode' for current tab buffer at last.
             (t
              (with-current-buffer tab-buffer
                (all-the-icons-icon-for-mode major-mode :v-adjust awesome-tab-icon-v-adjust :height awesome-tab-icon-height)
                )))))
      (when (and icon
                 ;; `get-text-property' need icon is string type.
                 (stringp icon))
        ;; Thanks ema2159 for code block ;)
        (propertize
         icon
         'face `(:inherit ,(get-text-property 0 'face icon)
                          :background ,background
                          ))))))

the profile tells me that

- awesome-tab-icon-for-tab              42522  45%
                           - if                                 42522  45%
                            - and                               42380  45%
                             - condition-case                   42374  45%
                                progn                           42374  45%

But the definition of awesome-tab-icon-for-tab contain none of if, and, condition-case and prog.

What happened?

Posted Feb 4, 2020, 3:02 PM UTC

12
eli-zaretskiiGNU Emacs maintainer•

It's the expansion of when and ignore-errors, which are macros.

4