After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 765363 - buffer: avoid damage to full buffer when removing matching brackets
buffer: avoid damage to full buffer when removing matching brackets
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
unspecified
Other All
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2016-04-21 06:34 UTC by Christian Hergert
Modified: 2016-04-22 08:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
buffer: avoid damage to full buffer when removing matching brackets (2.62 KB, patch)
2016-04-21 06:34 UTC, Christian Hergert
committed Details | Review

Description Christian Hergert 2016-04-21 06:34:28 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.
Comment 1 Christian Hergert 2016-04-21 06:34:37 UTC
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.
Comment 2 Paolo Borelli 2016-04-21 08:09:11 UTC
Why cannot gtk_text_buffer_remove_tag be smarter and invalidate only the actual range from the first tag toggle?
Comment 3 Christian Hergert 2016-04-21 22:06:54 UTC
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.
Comment 4 Christian Hergert 2016-04-22 08:53:30 UTC
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