Browse Source

Re-reserve the DebugRenderer vectors while they are empty to avoid unnecessary copying.

Lasse Öörni 13 years ago
parent
commit
69e14c4fe2
1 changed files with 7 additions and 4 deletions
  1. 7 4
      Engine/Graphics/DebugRenderer.cpp

+ 7 - 4
Engine/Graphics/DebugRenderer.cpp

@@ -429,11 +429,14 @@ bool DebugRenderer::IsInside(const BoundingBox& box) const
 void DebugRenderer::HandleEndFrame(StringHash eventType, VariantMap& eventData)
 {
     // When the amount of debug geometry is reduced, release memory
-    if (lines_.Capacity() > lines_.Size() * 2)
-        lines_.Compact();
-    if (noDepthLines_.Capacity() > noDepthLines_.Size() * 2)
-        noDepthLines_.Compact();
+    unsigned linesSize = lines_.Size();
+    unsigned noDepthLinesSize = noDepthLines_.Size();
     
     lines_.Clear();
     noDepthLines_.Clear();
+    
+    if (lines_.Capacity() > linesSize * 2)
+        lines_.Reserve(linesSize);
+    if (noDepthLines_.Capacity() > noDepthLinesSize * 2)
+        noDepthLines_.Reserve(noDepthLinesSize);
 }