Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2017-05-22 23:43:33 +0300
committerMike Erwin <significant.bit@gmail.com>2017-05-22 23:43:33 +0300
commit6cc293a6d97a2f8277660613a1ced9b2688bd7c0 (patch)
tree1d8eafc4941a6fe9ec03f22a080a40f0fcb90e6a /intern
parent845732652fa7a3d3a053006d30a76ea39fdc3c47 (diff)
Gawain: replace switch with lookup table
This function is not performance critical, but I prefer the branch-free code and no hack needed to appease gcc. Follow-up to recent 23035cf46fb4dd6a0bf7e688b0f15128030c77d1 and f637145450010d14660fcb029d41560a138eae14.
Diffstat (limited to 'intern')
-rw-r--r--intern/gawain/src/element.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/intern/gawain/src/element.c b/intern/gawain/src/element.c
index 1875c0a3cc8..425e3705003 100644
--- a/intern/gawain/src/element.c
+++ b/intern/gawain/src/element.c
@@ -28,19 +28,12 @@ static GLenum convert_index_type_to_gl(IndexType type)
unsigned ElementList_size(const ElementList* elem)
{
#if TRACK_INDEX_RANGE
- switch (elem->index_type)
- {
- case INDEX_U8: return elem->index_ct * sizeof(GLubyte);
- case INDEX_U16: return elem->index_ct * sizeof(GLushort);
- case INDEX_U32: return elem->index_ct * sizeof(GLuint);
-
- default:
-#if TRUST_NO_ONE
- assert(false);
-#endif
- return 0;
- }
-
+ static const unsigned table[] = {
+ [INDEX_U8] = sizeof(GLubyte), // GL has this, Vulkan does not
+ [INDEX_U16] = sizeof(GLushort),
+ [INDEX_U32] = sizeof(GLuint)
+ };
+ return elem->index_ct * table[elem->index_type];
#else
return elem->index_ct * sizeof(GLuint);
#endif