swift-emacs / swift-mode

Emacs support for Apple's Swift programming language.
GNU General Public License v3.0
363 stars 47 forks source link

Performance incompatible with which-function mode #180

Closed dabrahams closed 1 year ago

dabrahams commented 1 year ago

I commonly get really bad hangs traversing Swift files with which-function mode on. Here's a backtrace produced with debug-on-quit produced with point on line 2527 of this file:

Debugger entered--Lisp error: (quit)
  swift-mode:backward-token()
  swift-mode:backward-token-or-list()
  swift-mode:backward-sexps-until((implicit-\; \; { \( \[ "case" "default" ":"))
  swift-mode:case-colon-p()
  swift-mode:backward-token()
  swift-mode:backward-token-or-list()
  swift-mode:backward-sexps-until(({))
  swift-mode:class-like-member-p()
  swift-mode:find-defun-keyword()
  swift-mode:end-of-defun()
  swift-mode:containing-generic-block-region((85817 . 85817) swift-mode:end-of-defun swift-mode:beginning-of-defun)
  swift-mode:current-defun-name-token()
  swift-mode:current-defun-name-token-list()
  swift-mode:current-defun-name()
  #f(compiled-function () #<bytecode 0xf512c0cfb8587>)()
  run-hook-with-args-until-success(#f(compiled-function () #<bytecode 0xf512c0cfb8587>))
  which-function()
  which-func-update-1(#<window 212 on Parser.swift>)
  which-func-update()
  apply(which-func-update nil)
  timer-event-handler([t 0 0 500000 t which-func-update nil idle 0 nil])
dabrahams commented 1 year ago

Looks like #157 wasn't entirely fixed.

taku0 commented 1 year ago

Thank you for reporting this. Fixed: https://github.com/swift-emacs/swift-mode/commit/6d7093fb4a0b81686ffeff7e39f76027d83b7eb2. It was just very slow.