[gobject-introspection] giscanner: Define source and header filename extensions only once
- From: Dieter Verfaillie <dieterv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] giscanner: Define source and header filename extensions only once
- Date: Tue, 7 May 2013 14:07:41 +0000 (UTC)
commit b70fe6a5649ed037f2554ae13067fd9929d841f8
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date: Wed Apr 24 17:41:49 2013 +0200
giscanner: Define source and header filename extensions only once
Enables us to to use a more effecient list membership test
instead of testing the end of some string multiple times.
https://bugzilla.gnome.org/show_bug.cgi?id=699533
giscanner/scannermain.py | 7 ++-----
giscanner/sourcescanner.py | 7 +++++--
2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index b068f6f..deefcf9 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -38,7 +38,7 @@ from giscanner.girparser import GIRParser
from giscanner.girwriter import GIRWriter
from giscanner.maintransformer import MainTransformer
from giscanner.shlibs import resolve_shlibs
-from giscanner.sourcescanner import SourceScanner
+from giscanner.sourcescanner import SourceScanner, ALL_EXTS
from giscanner.transformer import Transformer
from . import utils
@@ -253,10 +253,7 @@ def extract_filenames(args):
for arg in args:
# We don't support real C++ parsing yet, but we should be able
# to understand C API implemented in C++ files.
- if (arg.endswith('.c') or arg.endswith('.cpp') or
- arg.endswith('.cc') or arg.endswith('.cxx') or
- arg.endswith('.h') or arg.endswith('.hpp') or
- arg.endswith('.hxx')):
+ if os.path.splitext(arg)[1] in ALL_EXTS:
if not os.path.exists(arg):
_error('%s: no such a file or directory' % (arg, ))
# Make absolute, because we do comparisons inside scannerparser.c
diff --git a/giscanner/sourcescanner.py b/giscanner/sourcescanner.py
index bd84a60..a1103a1 100644
--- a/giscanner/sourcescanner.py
+++ b/giscanner/sourcescanner.py
@@ -32,6 +32,10 @@ with LibtoolImporter(None, None):
else:
from giscanner._giscanner import SourceScanner as CSourceScanner
+HEADER_EXTS = ['.h', '.hpp', '.hxx']
+SOURCE_EXTS = ['.c', '.cpp', '.cc', '.cxx']
+ALL_EXTS = SOURCE_EXTS + HEADER_EXTS
+
(CSYMBOL_TYPE_INVALID,
CSYMBOL_TYPE_ELLIPSIS,
CSYMBOL_TYPE_CONST,
@@ -241,8 +245,7 @@ class SourceScanner(object):
headers = []
for filename in filenames:
- if (filename.endswith('.c') or filename.endswith('.cpp') or
- filename.endswith('.cc') or filename.endswith('.cxx')):
+ if os.path.splitext(filename)[1] in SOURCE_EXTS:
filename = os.path.abspath(filename)
self._scanner.lex_filename(filename)
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]