GNOME Bugzilla – Bug 765356
gutterrendererlines: micro-optimize ::query_data() for line gutter renderer
Last modified: 2016-04-21 22:08:01 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.
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.
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.
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.
Review of attachment 326463 [details] [review]: sure
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()