Branch: refs/heads/startup-speed Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Thu, 04 Feb 2021 22:30:19 UTC Commit: b0160ec162e4d34a73307d02d41e073aa96e6987 https://github.com/geany/geany/commit/b0160ec162e4d34a73307d02d41e073aa96e69...
Log Message: ----------- Avoid redundant margin computation when creating a new Scintilla widget
Avoid recomputing margin widths 2 or 3 times when initially creating the editing widget. As computing the margin widths might be costly, this can make widget creation about twice as fast.
Part of #2649.
Modified Paths: -------------- src/editor.c
Modified: src/editor.c 18 lines changed, 13 insertions(+), 5 deletions(-) =================================================================== @@ -4597,25 +4597,34 @@ void editor_ensure_final_newline(GeanyEditor *editor) }
-void editor_set_font(GeanyEditor *editor, const gchar *font) +/* Similar to editor_set_font() but *only* sets the font, and doesn't take care + * of updating properties that might depend on the font */ +static void set_font(ScintillaObject *sci, const gchar *font) { gint style; gchar *font_name; PangoFontDescription *pfd; gdouble size;
- g_return_if_fail(editor); + g_return_if_fail(sci);
pfd = pango_font_description_from_string(font); size = pango_font_description_get_size(pfd) / (gdouble) PANGO_SCALE; font_name = g_strdup_printf("!%s", pango_font_description_get_family(pfd)); pango_font_description_free(pfd);
for (style = 0; style <= STYLE_MAX; style++) - sci_set_font_fractional(editor->sci, style, font_name, size); + sci_set_font_fractional(sci, style, font_name, size);
g_free(font_name); +}
+ +void editor_set_font(GeanyEditor *editor, const gchar *font) +{ + g_return_if_fail(editor); + + set_font(editor->sci, font); update_margins(editor->sci); /* zoom to 100% to prevent confusion */ sci_zoom_off(editor->sci); @@ -4926,7 +4935,6 @@ static ScintillaObject *create_new_sci(GeanyEditor *editor)
setup_sci_keys(sci);
- sci_set_symbol_margin(sci, editor_prefs.show_markers_margin); sci_set_lines_wrapped(sci, editor->line_wrapping); sci_set_caret_policy_x(sci, CARET_JUMPS | CARET_EVEN, 0); /* Y policy is set in editor_apply_update_prefs() */ @@ -5000,7 +5008,7 @@ ScintillaObject *editor_create_widget(GeanyEditor *editor) editor->sci = sci;
editor_set_indent(editor, iprefs->type, iprefs->width); - editor_set_font(editor, interface_prefs.editor_font); + set_font(editor->sci, interface_prefs.editor_font); editor_apply_update_prefs(editor);
/* if editor already had a widget, restore it */
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).