summaryrefslogtreecommitdiff
path: root/giscanner/scannerlexer.l
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2012-04-05 14:12:11 -0300
committerJohan Dahlin <jdahlin@litl.com>2012-04-05 14:12:11 -0300
commit1c8927d147090fdc2c2f1f91d60a36cb69a19fe9 (patch)
tree7fe1788247911c445b36a84a83456d05b3c83846 /giscanner/scannerlexer.l
parente18dc76c6a0e9d30f1b45fd26fdb22e954d319df (diff)
downloadgobject-introspection-1c8927d147090fdc2c2f1f91d60a36cb69a19fe9.tar.gz
Do the filename filtering in scannerlexer
This avoids a bit of python work and reduces the amount of allocations.
Diffstat (limited to 'giscanner/scannerlexer.l')
-rw-r--r--giscanner/scannerlexer.l21
1 files changed, 17 insertions, 4 deletions
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index b4a6fac0..8ff6b7be 100644
--- a/giscanner/scannerlexer.l
+++ b/giscanner/scannerlexer.l
@@ -214,21 +214,29 @@ yywrap (void)
static void
parse_comment (GISourceScanner *scanner)
{
- GString *string;
+ GString *string = NULL;
int c1, c2;
GISourceComment *comment;
int comment_lineno;
+ int skip = FALSE;
+
+ if (!g_list_find_custom (scanner->filenames,
+ scanner->current_filename,
+ (GCompareFunc)g_strcmp0)) {
+ skip = TRUE;
+ } else {
+ string = g_string_new ("/*");
+ }
c1 = input();
c2 = input();
- string = g_string_new ("/*");
-
comment_lineno = lineno;
while (c2 != EOF && !(c1 == '*' && c2 == '/'))
{
- g_string_append_c (string, c1);
+ if (!skip)
+ g_string_append_c (string, c1);
if (c1 == '\n')
lineno++;
@@ -236,6 +244,11 @@ parse_comment (GISourceScanner *scanner)
c1 = c2;
c2 = input();
}
+
+ if (skip) {
+ return;
+ }
+
g_string_append (string, "*/");
comment = g_slice_new (GISourceComment);