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 765356 - gutterrendererlines: micro-optimize ::query_data() for line gutter renderer
gutterrendererlines: micro-optimize ::query_data() for line gutter renderer
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 01:58 UTC by Christian Hergert
Modified: 2016-04-21 22:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gutterrendererlines: don't use division to calculate number of digits (1.74 KB, patch)
2016-04-21 01:58 UTC, Christian Hergert
committed Details | Review
gutterrendererlines: remove allocations from ::query_data (2.50 KB, patch)
2016-04-21 01:58 UTC, Christian Hergert
committed Details | Review
gutterrendererlines: avoid extra function calls in ::query_data() (3.29 KB, patch)
2016-04-21 01:58 UTC, Christian Hergert
committed Details | Review

Description Christian Hergert 2016-04-21 01:58:25 UTC
The ::query_data() vfunc gets called quite a bit due to the lack of pixel
caching on GtkSourceView gutters. Cutting out a few unnecessary function
calls, mallocs, and such cuts the cost by about 30%.

Not hugely important, but I was there, and it was quick to fix.
Comment 1 Christian Hergert 2016-04-21 01:58:29 UTC
Created attachment 326463 [details] [review]
gutterrendererlines: don't use division to calculate number of digits

Avoid looping division to count digits. Not huge gains or anything, but
common to avoid loop+division in general. ~25% faster for numbers into
1000s.
Comment 2 Christian Hergert 2016-04-21 01:58:34 UTC
Created attachment 326464 [details] [review]
gutterrendererlines: remove allocations from ::query_data

This makes the cost of ::query_data() for the line gutter renderer
equivalent to the cost of the g_strdup_printf() previously.
Comment 3 Christian Hergert 2016-04-21 01:58:38 UTC
Created attachment 326465 [details] [review]
gutterrendererlines: avoid extra function calls in ::query_data()

We can remove the calls to check if the cursor is visible for every visible
line by keeping track of when the property changes. This removes a
gtk_text_view_get_cursor_visible() and gtk_text_gutter_render_get_view()
for every line in the rendering process.
Comment 4 Paolo Borelli 2016-04-21 08:13:07 UTC
Review of attachment 326463 [details] [review]:

sure
Comment 5 Christian Hergert 2016-04-21 22:07:50 UTC
Attachment 326463 [details] pushed as f524b60 - gutterrendererlines: don't use division to calculate number of digits
Attachment 326464 [details] pushed as 7230463 - gutterrendererlines: remove allocations from ::query_data
Attachment 326465 [details] pushed as c4008d3 - gutterrendererlines: avoid extra function calls in ::query_data()