diff options
author | mgrojo <mgrojo@gmail.com> | 2019-08-21 18:04:57 +0200 |
---|---|---|
committer | mgrojo <mgrojo@gmail.com> | 2019-08-21 18:04:57 +0200 |
commit | 301db9b9fa108339c74dc3936fbeaa779963ae24 (patch) | |
tree | fae966519774add2c604f62378273e58eeea7f5e | |
parent | ea0c67bb9ccf7b22e086f33bdb89f5aa12fc5a4f (diff) | |
download | ATCD-301db9b9fa108339c74dc3936fbeaa779963ae24.tar.gz |
Optimization: avoid invoking gettimeofday in each loop cycle
Constants can be moved outside the loop so delay is calculated just one and
gettimeofday is only called once for each invocation to cleanup (it is
assumed that the difference in time for each loop cycle is irrelevant for
the cleanup strategy).
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/Fragments_Cleanup_Strategy.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/Fragments_Cleanup_Strategy.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/Fragments_Cleanup_Strategy.cpp index d104c0691ba..456032c58ab 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/Fragments_Cleanup_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/Fragments_Cleanup_Strategy.cpp @@ -79,6 +79,10 @@ namespace TAO_PG TAO_UIPMC_Mcast_Transport::Packets_Map &packets ) { + // bound_ is in milliseconds. + ACE_Time_Value const delay (0, 1000 * this->bound_); + ACE_Time_Value const now = ACE_OS::gettimeofday (); + for (HASH_MAP_ITER iter = packets.begin (); iter != packets.end ();) { @@ -87,10 +91,6 @@ namespace TAO_PG // to removed entry. HASH_MAP_ITER cur_iter = iter++; - // bound_ is in milliseconds. - ACE_Time_Value const delay (0, 1000 * this->bound_); - ACE_Time_Value const now = ACE_OS::gettimeofday (); - if ((*cur_iter).item ()->started () != ACE_Time_Value::zero && now <= (*cur_iter).item ()->started () + delay) continue; |