Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Wed, 05 Nov 2014 20:50:07 UTC Commit: 29000cf10465ab739e688eee711ba14ecfbfba7f https://github.com/geany/geany/commit/29000cf10465ab739e688eee711ba14ecfbfba...
Log Message: ----------- Always parse buffer instead of file
This brings the linux kernel parsing time from about 20s to 12s on my machine.
Modified Paths: -------------- tagmanager/src/tm_source_file.c
Modified: tagmanager/src/tm_source_file.c 34 lines changed, 18 insertions(+), 16 deletions(-) =================================================================== @@ -253,15 +253,27 @@ gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gint g_warning("Attempt to parse NULL file"); return FALSE; } + + file_name = source_file->file_name; + + if (!use_buffer) + { + if (!g_file_get_contents(file_name, (gchar**)&text_buf, (gsize*)&buf_size, NULL)) + { + g_warning("Unable to open %s", file_name); + return FALSE; + } + }
- if (use_buffer && (NULL == text_buf || 0 == buf_size)) + if (NULL == text_buf || 0 == buf_size) { /* Empty buffer, "parse" by setting empty tag array */ tm_tags_array_free(source_file->tags_array, FALSE); + if (!use_buffer) + g_free(text_buf); return TRUE; }
- file_name = source_file->file_name; if (NULL == LanguageTable) { initializeParsing(); @@ -292,7 +304,7 @@ gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gint while (retry && passCount < 3) { tm_tags_array_free(source_file->tags_array, FALSE); - if (use_buffer && bufferOpen (text_buf, buf_size, file_name, source_file->lang)) + if (bufferOpen (text_buf, buf_size, file_name, source_file->lang)) { if (LanguageTable [source_file->lang]->parser != NULL) { @@ -305,19 +317,6 @@ gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gint retry = LanguageTable [source_file->lang]->parser2 (passCount); bufferClose (); } - else if (!use_buffer && fileOpen (file_name, source_file->lang)) - { - if (LanguageTable [source_file->lang]->parser != NULL) - { - LanguageTable [source_file->lang]->parser (); - fileClose (); - retry = FALSE; - break; - } - else if (LanguageTable [source_file->lang]->parser2 != NULL) - retry = LanguageTable [source_file->lang]->parser2 (passCount); - fileClose (); - } else { g_warning("Unable to open %s", file_name); @@ -326,6 +325,9 @@ gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gint ++ passCount; } } + + if (!use_buffer) + g_free(text_buf); return !retry; }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).