]> git.mxchange.org Git - flightgear.git/commitdiff
Performance optimization: empty() instead of size()>0
authorTom Paoletti <zommaso@gmail.com>
Fri, 22 Mar 2013 02:43:14 +0000 (19:43 -0700)
committerJames Turner <zakalawe@mac.com>
Mon, 19 Aug 2013 08:02:15 +0000 (09:02 +0100)
empty() is guaranteed to be constant complexity for both vectors and lists, while size() has linear complexity for lists.

src/Scripting/NasalSys.cxx

index a0ebb47046efce309adcfe9d1e8099755b3ad224..ca7dde87d5ed81a9e408f752bc117ec235dba5a9 100644 (file)
@@ -893,7 +893,7 @@ void FGNasalSys::loadScriptDirectory(simgear::Dir nasalDir)
 // Create module with list of scripts
 void FGNasalSys::addModule(string moduleName, simgear::PathList scripts)
 {
-    if (scripts.size()>0)
+    if (! scripts.empty())
     {
         SGPropertyNode* nasal = globals->get_props()->getNode("nasal");
         SGPropertyNode* module_node = nasal->getChild(moduleName,0,true);