GNOME Bugzilla – Bug 765363
buffer: avoid damage to full buffer when removing matching brackets
Last modified: 2016-04-22 08:53:33 UTC
I noticed while doing performance tuning in test-widget that we were damaging the full textview on every keypress as well as when the move-cursor stablizes (doing delayed bracket matching). This tries to minimize the damage area so that we avoid full redraws.
Created attachment 326470 [details] [review] buffer: avoid damage to full buffer when removing matching brackets When cleaning up matching brackets, gtk_text_buffer_remove_tag() is called for the entire buffer. This causes a damage in the view causing the entire pixelcache to be dropped. Further more, on every ::insert-text we perform the bracket updating meaning we damage the views on every keystroke. This walks the tag toggles manually to to reduce the ranges we damage to just the locations containing the tag.
Why cannot gtk_text_buffer_remove_tag be smarter and invalidate only the actual range from the first tag toggle?
Mentioned on IRC, but posting here as well. I don't think we want to change gtk_text_buffer_remove_tag() because that is optimized more for large numbers of tags potentially being in the buffer. Say you remove all tags highlighting "int" in a source file. That would be really expensive when instead you could just remove the index for that tag and invalidate the whole view.
Iterated on this a bit to make it safer (even though it doesn't matter since we only ever have tags that are 1 character apart). Attachment 326470 [details] pushed as 4ed97b3 - buffer: avoid damage to full buffer when removing matching brackets