From 159947ab68deea502b6a75cc7b38e461122111c9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 5 Dec 2019 09:52:16 -0500 Subject: [PATCH] VideoCommon/IndexGenerator: Make use of if constexpr We can use if constexpr with the template functions that pass in a non-type template parameter, allowing the removal of branches that aren't taken at compile time. Compilers will generally do this by default, however, we now give a gentle prodding to the compiler if this would otherwise not be the case. --- Source/Core/VideoCommon/IndexGenerator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/IndexGenerator.cpp b/Source/Core/VideoCommon/IndexGenerator.cpp index e0a0db8e04..338cdfa9f9 100644 --- a/Source/Core/VideoCommon/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/IndexGenerator.cpp @@ -26,7 +26,7 @@ u16* WriteTriangle(u16* index_ptr, u32 index1, u32 index2, u32 index3) *index_ptr++ = index1; *index_ptr++ = index2; *index_ptr++ = index3; - if (pr) + if constexpr (pr) *index_ptr++ = s_primitive_restart; return index_ptr; } @@ -44,7 +44,7 @@ u16* AddList(u16* index_ptr, u32 num_verts, u32 index) template u16* AddStrip(u16* index_ptr, u32 num_verts, u32 index) { - if (pr) + if constexpr (pr) { for (u32 i = 0; i < num_verts; ++i) { @@ -89,7 +89,7 @@ u16* AddFan(u16* index_ptr, u32 num_verts, u32 index) { u32 i = 2; - if (pr) + if constexpr (pr) { for (; i + 3 <= num_verts; i += 3) { @@ -141,7 +141,7 @@ u16* AddQuads(u16* index_ptr, u32 num_verts, u32 index) u32 i = 3; for (; i < num_verts; i += 4) { - if (pr) + if constexpr (pr) { *index_ptr++ = index + i - 2; *index_ptr++ = index + i - 1;