[Saga-devel] saga SVN commit 3315: /trunk/saga/saga/adaptors/utils/
amerzky at cct.lsu.edu
amerzky at cct.lsu.edu
Sat Jan 17 05:53:56 CST 2009
User: amerzky
Date: 2009/01/17 05:53 AM
Modified:
/trunk/saga/saga/adaptors/utils/
utils.cpp
Log:
optimization: create hostlist only once (static vector)
A
File Changes:
Directory: /trunk/saga/saga/adaptors/utils/
===========================================
File [modified]: utils.cpp
Delta lines: +14 -4
===================================================================
--- trunk/saga/saga/adaptors/utils/utils.cpp 2009-01-17 11:51:13 UTC (rev 3314)
+++ trunk/saga/saga/adaptors/utils/utils.cpp 2009-01-17 11:53:48 UTC (rev 3315)
@@ -142,7 +142,7 @@
bool host_is_localhost (std::string host)
{
- std::vector <std::strings> localhosts = get_localhosts ();
+ std::vector <std::string> localhosts = get_localhosts ();
for ( int i = 0; i < localhosts.size (); i++ )
{
if ( host == localhosts[i] )
@@ -177,8 +177,17 @@
{
std::set <std::string> initial_names;
std::set <std::string> names;
- std::vector <std::string> ret;
+ // optimization: build this list only once - we assume that host names
+ // do not change during the runtime of the SAGA application.
+ static std::vector <std::string> localhosts;
+ static bool have_localhosts = false;
+
+ if ( have_localhosts )
+ {
+ return localhosts;
+ }
+
// default initial candidate
initial_names.insert ("localhost");
@@ -257,10 +266,11 @@
it != names.end ();
it++ )
{
- ret.push_back (*it);
+ localhosts.push_back (*it);
}
- return ret;
+ have_localhosts = true;
+ return localhosts;
}
bool url_is_local (const saga::url & url)
More information about the saga-devel
mailing list