]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/logger.cxx
Performance optimization: empty() instead of size()>0
[flightgear.git] / src / Main / logger.cxx
index 71ee3f5546c7801be888b1fdbebb3b49d1aae742..0e8109e0df7b8b6f8b54393d26bd3a487ce0534d 100644 (file)
@@ -3,20 +3,21 @@
 //
 // This file is in the Public Domain, and comes with no warranty.
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include "logger.hxx"
 
 #include <fstream>
 #include <string>
 
-using std::ofstream;
-using std::endl;
-using std::string;
-
 #include <simgear/debug/logstream.hxx>
 
 #include "fg_props.hxx"
 
-
+using std::string;
+using std::endl;
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGLogger
@@ -37,7 +38,7 @@ FGLogger::init ()
   if (logging == 0)
     return;
 
-  vector<SGPropertyNode_ptr> children = logging->getChildren("log");
+  std::vector<SGPropertyNode_ptr> children = logging->getChildren("log");
   for (unsigned int i = 0; i < children.size(); i++) {
 
     SGPropertyNode * child = children[i];
@@ -49,13 +50,13 @@ FGLogger::init ()
     Log &log = _logs[_logs.size()-1];
     
     string filename = child->getStringValue("filename");
-    if (filename.size() == 0) {
+    if (filename.empty()) {
         filename = "fg_log.csv";
         child->setStringValue("filename", filename.c_str());
     }
 
     string delimiter = child->getStringValue("delimiter");
-    if (delimiter.size() == 0) {
+    if (delimiter.empty()) {
         delimiter = ",";
         child->setStringValue("delimiter", delimiter.c_str());
     }
@@ -63,16 +64,16 @@ FGLogger::init ()
     log.interval_ms = child->getLongValue("interval-ms");
     log.last_time_ms = globals->get_sim_time_sec() * 1000;
     log.delimiter = delimiter.c_str()[0];
-    log.output = new ofstream(filename.c_str());
+    log.output = new std::ofstream(filename.c_str());
     if (!log.output) {
-      SG_LOG(SG_INPUT, SG_ALERT, "Cannot write log to " << filename);
+      SG_LOG(SG_GENERAL, SG_ALERT, "Cannot write log to " << filename);
       continue;
     }
 
     //
     // Process the individual entries (Time is automatic).
     //
-    vector<SGPropertyNode_ptr> entries = child->getChildren("entry");
+    std::vector<SGPropertyNode_ptr> entries = child->getChildren("entry");
     (*log.output) << "Time";
     for (unsigned int j = 0; j < entries.size(); j++) {
       SGPropertyNode * entry = entries[j];
@@ -92,7 +93,7 @@ FGLogger::init ()
        fgGetNode(entry->getStringValue("property"), true);
       log.nodes.push_back(node);
       (*log.output) << log.delimiter
-                   << entry->getStringValue("title", node->getPath());
+                   << entry->getStringValue("title", node->getPath().c_str());
     }
     (*log.output) << endl;
   }