optmize std::map comparison
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 12 Dec 2006 14:41:52 +0100
changeset 196 9d243651d00c
parent 195 c4a63ac2c5de
child 197 8346ab3528bf
optmize std::map comparison
src/simulator/scheduler-map.cc
src/simulator/scheduler-map.h
--- a/src/simulator/scheduler-map.cc	Tue Dec 12 14:41:39 2006 +0100
+++ b/src/simulator/scheduler-map.cc	Tue Dec 12 14:41:52 2006 +0100
@@ -49,16 +49,20 @@
  * - transitivity: f(x,y) and f(y,z) => f(x,z)
  */
 bool
-SchedulerMap::EventKeyCompare::operator () (struct EventKey a, struct EventKey b)
+SchedulerMap::EventKeyCompare::operator () (struct EventKey const&a, struct EventKey const&b)
 {
   if (a.m_ns < b.m_ns) 
     {
       return true;
     } 
-  else if (a.m_ns == b.m_ns && a.m_uid < b.m_uid) 
+  else if (a.m_ns > b.m_ns)
+    {
+      return false;
+    } 
+  else if (a.m_uid < b.m_uid)
     {
       return true;
-    } 
+    }
   else 
     {
       return false;
--- a/src/simulator/scheduler-map.h	Tue Dec 12 14:41:39 2006 +0100
+++ b/src/simulator/scheduler-map.h	Tue Dec 12 14:41:52 2006 +0100
@@ -47,7 +47,7 @@
 
   class EventKeyCompare {
   public:
-    bool operator () (struct EventKey a, struct EventKey b);
+    bool operator () (struct EventKey const&a, struct EventKey const&b);
   };
 
   typedef std::map<Scheduler::EventKey, EventImpl*, SchedulerMap::EventKeyCompare> EventMap;