Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Do the filename filtering in scannerlexer
Browse files Browse the repository at this point in the history
This avoids a bit of python work and reduces the
amount of allocations.
  • Loading branch information
boondocksaints-debug authored and jdahlin-litl committed Apr 5, 2012
1 parent e18dc76 commit 1c8927d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
21 changes: 17 additions & 4 deletions giscanner/scannerlexer.l
Expand Up @@ -214,28 +214,41 @@ 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++;

c1 = c2;
c2 = input();
}

if (skip) {
return;
}

g_string_append (string, "*/");

comment = g_slice_new (GISourceComment);
Expand Down
5 changes: 1 addition & 4 deletions giscanner/sourcescanner.py
Expand Up @@ -259,10 +259,7 @@ def get_symbols(self):
yield SourceSymbol(self._scanner, symbol)

def get_comments(self):
for comment in self._scanner.get_comments():
filename = comment[-2]
if filename in self._filenames:
yield comment
return self._scanner.get_comments()

def dump(self):
print '-'*30
Expand Down

0 comments on commit 1c8927d

Please sign in to comment.