From f10f1b2e2ddff45cd590e920c447c7a2a22882cb Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Mon, 20 Jan 2020 16:50:00 +0200
Subject: [PATCH] Minor optim for data channel

---
 components/rgbd-sources/include/ftl/rgbd/frame.hpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/components/rgbd-sources/include/ftl/rgbd/frame.hpp b/components/rgbd-sources/include/ftl/rgbd/frame.hpp
index 69ed68746..9bdbea420 100644
--- a/components/rgbd-sources/include/ftl/rgbd/frame.hpp
+++ b/components/rgbd-sources/include/ftl/rgbd/frame.hpp
@@ -477,8 +477,10 @@ void Frame::create(ftl::codecs::Channel channel, const T &value) {
 	if (static_cast<int>(channel) < static_cast<int>(ftl::codecs::Channel::Data)) throw ftl::exception("Cannot use generic type with non data channel");
 
 	data_channels_ += channel;
-	data_data_.insert({static_cast<int>(channel),{}});
-	ftl::util::FTLVectorBuffer buf(data_data_[static_cast<int>(channel)]);
+
+	auto &v = *std::get<0>(data_data_.insert({static_cast<int>(channel),{}}));
+	v.second.resize(0);
+	ftl::util::FTLVectorBuffer buf(v.second);
 	msgpack::pack(buf, value);
 }
 
-- 
GitLab