nim-lang / nim-mode

An emacs major mode for the Nim programming language
138 stars 46 forks source link

remove save-excursion; add local fontification #200

Closed krux02 closed 5 years ago

krux02 commented 6 years ago

fix for #198

I had an e-mail with Anders Lindgren and asked for help to improve the situation on the performance, his words were the following:

After looking at the code, the big problem with it is that it doesn't respect the search limit. The background is that font-lock only highlights parts of a buffer at a time. When editing, this typically is only the line where the editing takes place. (You can use my package highlight-refontification to visualize this.) In your code, the limit is incorrectly named _start-pos and never used, with the effect that it searches outside the region that is being updated, which could be very expensive for large buffers.

Fixing only this has already big improvements on the performance.

I also removed the save-excursion call, because it is unnecessary.

test cases are all still passing, and editing gl.nim is possible again.

pigmej commented 6 years ago

That looks ok to me. Let's wait a while for @yuutayamada maybe he would have some objections.