Always parse buffer instead of file
This brings the linux kernel parsing time from about 20s to 12s on my machine.
This commit is contained in:
parent
448f1fd20e
commit
29000cf104
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user