From b2e45e28fa60dec8c30ee3e5aa5f6384fb03d78a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Sep 2019 01:07:43 -0400 Subject: [PATCH] View: Implement load() in terms of the other Same thing, but with less code duplication. --- specter/include/specter/View.hpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/specter/include/specter/View.hpp b/specter/include/specter/View.hpp index eee603430..0412dec71 100644 --- a/specter/include/specter/View.hpp +++ b/specter/include/specter/View.hpp @@ -111,20 +111,15 @@ public: void load(const VertStruct* data, size_t count) { if (m_vertsBuf) { - VertStruct* out = m_vertsBuf.access(); - for (size_t i = 0; i < count; ++i) - out[i] = data[i]; + VertStruct* const out = m_vertsBuf.access(); + std::copy(data, data + count, out); } } template void load(const VertArray data) { - static_assert(std::is_same, VertStruct>::value, "mismatched type"); - if (m_vertsBuf) { - constexpr size_t count = sizeof(VertArray) / sizeof(VertStruct); - VertStruct* out = m_vertsBuf.access(); - for (size_t i = 0; i < count; ++i) - out[i] = data[i]; - } + static_assert(std::is_same_v, VertStruct>, "mismatched type"); + constexpr size_t count = sizeof(VertArray) / sizeof(VertStruct); + load(data, count); } operator const boo::ObjToken&() { return m_shaderBinding; }