diff gen/toobj.cpp @ 994:18ad5601dff7

Use LLVM OStream wrapper instead of <iostream> in the logger. llvm::OStream provides all std::ostream functionality (by holding a std::ostream* internally), but * doesn't include <iostream>, avoiding per-file overhead. * allows the stream pointer to be null, and the (inlined) operators do nothing when that's the case. (This also allows removal of the ofstream("/dev/null") hack Logger used when disabled, which presumably wasn't very portable)
author Frits van Bommel <fvbommel wxs.nl>
date Thu, 26 Feb 2009 14:51:02 +0100
parents 27956b440c0a
children 5aa5d25508c6
line wrap: on
line diff
--- a/gen/toobj.cpp	Thu Feb 26 15:24:20 2009 +0100
+++ b/gen/toobj.cpp	Thu Feb 26 14:51:02 2009 +0100
@@ -8,7 +8,6 @@
 // See the included readme.txt for details.
 
 #include <cstddef>
-#include <iostream>
 #include <fstream>
 
 #include "gen/llvm.h"
@@ -344,13 +343,15 @@
         Args.push_back(args[i].c_str());
     Args.push_back(0);
 
-    Logger::println("Assembling with: ");
-    std::vector<const char*>::const_iterator I = Args.begin(), E = Args.end(); 
-    std::ostream& logstr = Logger::cout();
-    for (; I != E; ++I)
-        if (*I)
-            logstr << "'" << *I << "'" << " ";
-    logstr << "\n" << std::flush;
+    if (Logger::enabled()) {
+        Logger::println("Assembling with: ");
+        std::vector<const char*>::const_iterator I = Args.begin(), E = Args.end();
+        std::ostream& logstr = *Logger::cout().stream();
+        for (; I != E; ++I)
+            if (*I)
+                logstr << "'" << *I << "'" << " ";
+        logstr << "\n" << std::flush;
+    }
 
     // Run the compiler to assembly the program.
     std::string ErrMsg;