Browse Source

optimization

David Rose 24 years ago
parent
commit
a495248019
1 changed files with 7 additions and 1 deletions
  1. 7 1
      panda/src/tform/mouseWatcherGroup.cxx

+ 7 - 1
panda/src/tform/mouseWatcherGroup.cxx

@@ -41,14 +41,20 @@ bool MouseWatcherGroup::
 add_region(MouseWatcherRegion *region) {
   //return _regions.insert(region).second;
 
-  // See if the region is in the set/vector already
   PT(MouseWatcherRegion) pt = region;
+
+  // We will only bother to check for duplicates in the region list if
+  // we are building opt 1 or 2.  The overhead for doing this may be
+  // too high if we have many regions.
+#ifdef _DEBUG
+  // See if the region is in the set/vector already
   Regions::const_iterator ri = 
     find(_regions.begin(), _regions.end(), pt);
   if (ri != _regions.end()) {
     // Already in the set, return false
     return false;
   }
+#endif
 
   // Not in the set, add it and return true
   _regions.push_back(pt);