From 8640d845d06e2bc233de6669efec4c8bb2fc1f13 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Mon, 28 Mar 2011 20:36:06 +0000 Subject: [PATCH] Don't update parent WorkObjects when updating one in real-time Updating the parent may lead to performance issues if an object have too many parents since they are updated recursively. Parent objects are still updated when saving the file. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5642 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 7 +++++++ src/document.c | 16 ++++++++-------- src/document.h | 2 +- src/editor.c | 2 +- src/keybindings.c | 2 +- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index fdbebd48..79a8519d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-03-28 Colomban Wendling + + * src/document.c, src/document.h, src/editor.c, src/keybindings.c: + Don't update parent WorkObjects when updating one in real-time. This + should fix some performance issues if a WorkObject has many parents. + + 2011-03-27 Enrico Tröger * src/makefile.win32, src/main.c, src/Makefile.am, configure.ac, diff --git a/src/document.c b/src/document.c index 9063a538..db25232b 100644 --- a/src/document.c +++ b/src/document.c @@ -109,7 +109,7 @@ typedef struct static void document_undo_clear(GeanyDocument *doc); static void document_redo_add(GeanyDocument *doc, guint type, gpointer data); -static gboolean update_tags_from_buffer(GeanyDocument *doc); +static gboolean update_tags_from_buffer(GeanyDocument *doc, gboolean update_parent); /* ignore the case of filenames and paths under WIN32, causes errors if not */ @@ -771,7 +771,7 @@ GeanyDocument *document_new_file(const gchar *utf8_filename, GeanyFiletype *ft, ui_set_window_title(doc); build_menu_update(doc); - document_update_tag_list(doc, FALSE); + document_update_tag_list(doc, FALSE, TRUE); document_set_text_changed(doc, FALSE); ui_document_show_hide(doc); /* update the document menu */ @@ -2250,7 +2250,7 @@ gint document_replace_all(GeanyDocument *doc, const gchar *find_text, const gcha } -static gboolean update_tags_from_buffer(GeanyDocument *doc) +static gboolean update_tags_from_buffer(GeanyDocument *doc, gboolean update_parent) { gboolean result; #if 0 @@ -2263,14 +2263,14 @@ static gboolean update_tags_from_buffer(GeanyDocument *doc) /* we copy the whole text into memory instead using a direct char pointer from * Scintilla because tm_source_file_buffer_update() does modify the string slightly */ sci_get_text(doc->editor->sci, len, text); - result = tm_source_file_buffer_update(doc->tm_file, (guchar*) text, len, TRUE); + result = tm_source_file_buffer_update(doc->tm_file, (guchar*) text, len, update_parent); g_free(text); #endif return result; } -void document_update_tag_list(GeanyDocument *doc, gboolean update) +void document_update_tag_list(GeanyDocument *doc, gboolean update, gboolean update_parent) { /* We must call sidebar_update_tag_list() before returning, * to ensure that the symbol list is always updated properly (e.g. @@ -2306,14 +2306,14 @@ void document_update_tag_list(GeanyDocument *doc, gboolean update) else { if (update) - update_tags_from_buffer(doc); + update_tags_from_buffer(doc, update_parent); success = TRUE; } } } else { - success = update_tags_from_buffer(doc); + success = update_tags_from_buffer(doc, update_parent); if (G_UNLIKELY(! success)) geany_debug("tag list updating failed"); } @@ -2449,7 +2449,7 @@ static void document_load_config(GeanyDocument *doc, GeanyFiletype *type, doc->priv->symbol_list_sort_mode = type->priv->symbol_list_sort_mode; } - document_update_tag_list(doc, TRUE); + document_update_tag_list(doc, TRUE, TRUE); /* Update session typename keywords. */ update_type_keywords(doc, type->lang); diff --git a/src/document.h b/src/document.h index 27240c8f..564313c0 100644 --- a/src/document.h +++ b/src/document.h @@ -229,7 +229,7 @@ gint document_replace_all(GeanyDocument *doc, const gchar *find_text, const gcha void document_replace_sel(GeanyDocument *doc, const gchar *find_text, const gchar *replace_text, gint flags, gboolean escaped_chars); -void document_update_tag_list(GeanyDocument *doc, gboolean update); +void document_update_tag_list(GeanyDocument *doc, gboolean update, gboolean update_parent); void document_set_encoding(GeanyDocument *doc, const gchar *new_encoding); diff --git a/src/editor.c b/src/editor.c index 6a5a0aeb..c093e9c8 100644 --- a/src/editor.c +++ b/src/editor.c @@ -999,7 +999,7 @@ static gboolean on_document_update_tags_idle(gpointer data) GeanyDocument *doc = data; if (!main_status.quitting && DOC_VALID(doc)) - document_update_tag_list(doc, TRUE); + document_update_tag_list(doc, TRUE, FALSE); document_tags_update_pending = FALSE; return FALSE; diff --git a/src/keybindings.c b/src/keybindings.c index 4e85a84b..9076fb7f 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -2524,7 +2524,7 @@ static gboolean cb_func_document_action(guint key_id) ui_document_show_hide(doc); break; case GEANY_KEYS_DOCUMENT_RELOADTAGLIST: - document_update_tag_list(doc, TRUE); + document_update_tag_list(doc, TRUE, TRUE); break; case GEANY_KEYS_DOCUMENT_FOLDALL: editor_fold_all(doc->editor);