Maybe the field functions are slow. I replaced the field functions with point-min and point-max (narrow-to-region (point-min) (point-max)) and the overhead disappeared. Kang Niu 于2021年12月19日周日 23:19写道: > Seems now the let clause undertake the overhead: > Samples % Function > > > 7230 77% - symbol-overlay-post-command > 7227 77% - if > 7183 77% - string= > 7180 77% - symbol-overlay-get-symbol > 7180 77% - or > 7176 77% - thing-at-point > 7163 77% - save-restriction > 7138 76% - let > 221 2% - cond > 206 2% + let > 2 0% let* > 7 0% + if > 40 0% + symbol-overlay-remove-temp > 1234 13% - command-execute > 1215 13% - call-interactively > 1205 12% - funcall-interactively > 783 8% + next-line > 415 4% + previous-line > 7 0% + execute-extended-command > 3 0% + byte-code > 358 3% + ... > 255 2% + redisplay_internal (C function) > 156 1% + timer-event-handler > 25 0% + undo-auto--add-boundary > 18 0% + jit-lock--antiblink-post-command > 17 0% + internal-timer-start-idle > 8 0% + clear-minibuffer-message > > Lars Ingebrigtsen 于2021年12月19日周日 22:44写道: > >> Kang Niu writes: >> >> > There are no fields in the buffer. (field-beginning) (field-end) return >> the same value >> > as (point-min) (point-max). >> >> Odd. Does the following fix the performance problem? I'm wondering >> whether it's the field functions that are slow or whether the >> narrow-to-region is the thing that somehow triggers the slowness. >> >> diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el >> index 2d1bf2013e..e746d94080 100644 >> --- a/lisp/thingatpt.el >> +++ b/lisp/thingatpt.el >> @@ -178,7 +178,11 @@ thing-at-point >> See the file `thingatpt.el' for documentation on how to define >> a symbol as a valid THING." >> (save-restriction >> - (narrow-to-region (field-beginning) (field-end)) >> + (let ((beg (field-beginning)) >> + (end (field-end))) >> + (when (or (not (= beg (point-min))) >> + (not (= end (point-max)))) >> + (narrow-to-region (field-beginning) (field-end)))) >> (let ((text >> (cond >> ((cl-loop for (pthing . function) in >> thing-at-point-provider-alist >> >> >> -- >> (domestic pets only, the antidote for overdose, milk.) >> bloggy blog: http://lars.ingebrigtsen.no >> >