From 875c6e81e5ed52df46740083451380c4597b560c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 24 Jul 2017 14:08:26 +0200 Subject: Optimize C/C++ lexer --- unit-tests/cc/parser/driver.cxx | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'unit-tests/cc/parser') diff --git a/unit-tests/cc/parser/driver.cxx b/unit-tests/cc/parser/driver.cxx index ec346d3..19d85e8 100644 --- a/unit-tests/cc/parser/driver.cxx +++ b/unit-tests/cc/parser/driver.cxx @@ -11,6 +11,7 @@ #include using namespace std; +using namespace butl; namespace build2 { @@ -23,27 +24,22 @@ namespace build2 { try { - istream* is; - const char* in; + const char* file; - // Reading from file is several times faster. - // - ifdstream ifs; + ifdstream is; if (argc > 1) { - in = argv[1]; - ifs.open (in); - is = &ifs; + file = argv[1]; + is.open (file); } else { - in = "stdin"; - cin.exceptions (istream::failbit | istream::badbit); - is = &cin; + file = "stdin"; + is.open (fddup (stdin_fd ())); } parser p; - translation_unit u (p.parse (*is, path (in))); + translation_unit u (p.parse (is, path (file))); for (const module_import& m: u.mod.imports) cout << (m.exported ? "export " : "") -- cgit v1.1