lua-mode icon indicating copy to clipboard operation
lua-mode copied to clipboard

Extremely slow indentation inside tables

Open cigumo opened this issue 3 years ago • 3 comments

I've just updated to the latest version in mepla (20210809) and it's extremely slow indenting tables.

Here's an example:

    100 = {a='b', c=2},
    101 = {a='b', c=2},
    102 = {a='b', c=2},
    ...  (500 more lines) 
}

It takes 40 seconds to indent it!

Here's a profiler report:

- command-execute                                               20021  89%
 - call-interactively                                           20021  89%
  - funcall-interactively                                       19931  88%
   - indent-region                                              19855  88%
    - indent-region-line-by-line                                19854  88%
     - indent-according-to-mode                                 19802  88%
      - lua-indent-line                                         19802  88%
       - lua-calculate-indentation                              19765  87%
        - lua-calculate-indentation-block-modifier              19677  87%
         - lua-calculate-indentation-info                       19677  87%
          - lua-is-continuing-statement-p                       19624  87%
           - lua-is-continuing-statement-p-1                    19605  87%
            - lua--backward-up-list-noerror                     19533  86%
             - lua-backward-up-list                             19512  86%
              - lua-find-matching-token-word                     9865  43%
               + lua-find-regexp                                 9584  42%
                 lua-get-block-token-info                          49   0%
              - lua-find-regexp                                  9419  41%
               - lua-comment-or-string-p                         9101  40%
                - syntax-ppss                                    8911  39%
                   #<compiled 0x1ff9b7316815>                       6   0%
                + lua-comment-start-pos                            34   0%
                match-string-no-properties                         48   0%
                lua-get-block-token-info                           34   0%
            + lua-last-token-continues-p                           29   0%
            + lua-forward-line-skip-blanks                         28   0%
            + lua--continuation-breaking-line-p                     9   0%
            + lua-first-token-continues-p                           6   0%
           + lua--goto-line-beginning-rightmost-closer                 16   0%
          + lua-calculate-indentation-info-1                       46   0%
            back-to-indentation                                     3   0%
        + lua-calculate-indentation-override                       60   0%
        + lua-forward-line-skip-blanks                             28   0%
       + lua-comment-or-string-p                                   36   0%
         back-to-indentation                                        1   0%
       progress-reporter-do-update                                 51   0%
   + execute-extended-command                                      76   0%

Thanks!

cigumo avatar Nov 08 '21 18:11 cigumo

Tested in emacs 27.1 and 27.2 on a Mac.

cigumo avatar Nov 08 '21 18:11 cigumo

Hi,

I'll try to have a look at this over the weekend. Thank you for the report!

immerrr avatar Nov 11 '21 13:11 immerrr

Thanks!!! It's really making my life miserable and I don't have time to fix it myself for the rest of the month. :)

cigumo avatar Nov 11 '21 13:11 cigumo