summaryrefslogtreecommitdiff
path: root/giscanner/giscannermodule.c
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2013-10-17 17:26:10 +0200
committerColin Walters <walters@verbum.org>2013-10-17 15:03:26 -0400
commit65a0fa4c4e005047af7ec029c733bed4bd80292f (patch)
treefb76a7fec121c54827b0eaef946d25e1732464af /giscanner/giscannermodule.c
parent69d2fe30289795b3daf099a5f84ff9216dc6ed44 (diff)
downloadgobject-introspection-65a0fa4c4e005047af7ec029c733bed4bd80292f.tar.gz
giscanner: speed up SourceScanner().parse_files()
Was looking around a bit and noticed about 2/3 of g-ir-scanner time is spent in SourceScanner().parse_files(). Some profiling quickly shows most of that 2/3 is used by gi_source_scanner_add_symbol() where it creates a whole bunch of GFile instances just to compare paths and throw them away again. With this a scanner instance now maintains a hash table of GFile instances instead of a list of file names, so comparing those paths can be reduced to a fast g_hash_table_contains() call. This makes "g-ir-scanner <whole_bunch_of_options> --output Gtk-3.0.gir" complete in about 10 seconds on my box instead of about 30 seconds (both best of 3 runs). https://bugzilla.gnome.org/show_bug.cgi?id=710320
Diffstat (limited to 'giscanner/giscannermodule.c')
-rw-r--r--giscanner/giscannermodule.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/giscanner/giscannermodule.c b/giscanner/giscannermodule.c
index 182d8438..2f4c0e8a 100644
--- a/giscanner/giscannermodule.c
+++ b/giscanner/giscannermodule.c
@@ -356,12 +356,13 @@ pygi_source_scanner_append_filename (PyGISourceScanner *self,
PyObject *args)
{
char *filename;
+ GFile *file;
if (!PyArg_ParseTuple (args, "s:SourceScanner.append_filename", &filename))
return NULL;
- self->scanner->filenames = g_list_append (self->scanner->filenames,
- g_realpath (filename));
+ file = g_file_new_for_path (g_realpath (filename));
+ g_hash_table_add (self->scanner->files, file);
Py_INCREF (Py_None);
return Py_None;
@@ -511,18 +512,19 @@ pygi_source_scanner_lex_filename (PyGISourceScanner *self,
PyObject *args)
{
char *filename;
+ GFile *file;
if (!PyArg_ParseTuple (args, "s:SourceScanner.lex_filename", &filename))
return NULL;
- self->scanner->current_filename = g_realpath (filename);
+ self->scanner->current_file = g_file_new_for_path ( g_realpath (filename));
if (!gi_source_scanner_lex_filename (self->scanner, filename))
{
g_print ("Something went wrong during lexing.\n");
return NULL;
}
- self->scanner->filenames =
- g_list_append (self->scanner->filenames, g_strdup (filename));
+ file = g_file_new_for_path (filename);
+ g_hash_table_add (self->scanner->files, file);
Py_INCREF (Py_None);
return Py_None;