瀏覽代碼

AA branch: Minor optimisations for Debug builds

ocornut 10 年之前
父節點
當前提交
5bf30bd6c4
共有 1 個文件被更改,包括 7 次插入6 次删除
  1. 7 6
      imgui.cpp

+ 7 - 6
imgui.cpp

@@ -8981,8 +8981,8 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
         // Temporary buffer
         GTempPolyData.resize(points_count * 3);
         ImVec2* temp_inner = &GTempPolyData[0];
-        ImVec2* temp_outer = &GTempPolyData[points_count];
-        ImVec2* temp_normals = &GTempPolyData[points_count * 2];
+        ImVec2* temp_outer = temp_inner + points_count;
+        ImVec2* temp_normals = temp_inner + points_count * 2;
 
         for (int i = 0; i < count; i++)
         {
@@ -9095,8 +9095,9 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
         // Temporary buffer
         GTempPolyData.resize(points_count * 3);
         ImVec2* temp_inner = &GTempPolyData[0];
-        ImVec2* temp_outer = &GTempPolyData[points_count];
-        ImVec2* temp_normals = &GTempPolyData[points_count * 2];
+        ImVec2* temp_outer = temp_inner + points_count;
+        ImVec2* temp_normals = temp_inner + points_count + 2;
+
         for (int i = 0, j = points_count-1; i < points_count; j=i++)
         {
             const ImVec2& v0 = points[j];
@@ -9239,9 +9240,9 @@ void ImDrawList::Rect(const ImVec2& a, const ImVec2& b, float rounding, int roun
 
     if (r == 0.0f || rounding_corners == 0)
     {
-        LineTo(ImVec2(a.x,a.y));
+        LineTo(a);
         LineTo(ImVec2(b.x,a.y));
-        LineTo(ImVec2(b.x,b.y));
+        LineTo(b);
         LineTo(ImVec2(a.x,b.y));
     }
     else