Optimize away a few memory allocations
This commit is contained in:
@@ -124,6 +124,7 @@ void scenes::stream::tracking()
|
||||
const XrDuration dt = 100'000; // Wake up 0.1ms before measuring the position
|
||||
|
||||
XrTime t0 = instance.now();
|
||||
from_headset::tracking packet{};
|
||||
|
||||
while (not exiting)
|
||||
{
|
||||
@@ -142,7 +143,6 @@ void scenes::stream::tracking()
|
||||
// 1 or 2 samples
|
||||
for (XrDuration Δt = 0; Δt <= prediction; Δt += std::max<XrDuration>(1, prediction))
|
||||
{
|
||||
from_headset::tracking packet{};
|
||||
from_headset::hand_tracking hands{};
|
||||
|
||||
packet.production_timestamp = t0;
|
||||
@@ -164,6 +164,7 @@ void scenes::stream::tracking()
|
||||
|
||||
packet.flags = flags;
|
||||
|
||||
packet.device_poses.clear();
|
||||
for (auto [device, space]: spaces)
|
||||
{
|
||||
packet.device_poses.push_back(locate_space(device, space, world_space, t0 + Δt));
|
||||
|
||||
@@ -292,7 +292,8 @@ void xrt::drivers::wivrn::UDP::send_raw(const std::vector<uint8_t> & data)
|
||||
|
||||
void xrt::drivers::wivrn::UDP::send_raw(const std::vector<std::span<uint8_t>> & data)
|
||||
{
|
||||
std::vector<iovec> spans;
|
||||
thread_local std::vector<iovec> spans;
|
||||
spans.clear();
|
||||
for (const auto & span: data)
|
||||
spans.emplace_back((void *)span.data(), span.size());
|
||||
|
||||
@@ -344,7 +345,8 @@ xrt::drivers::wivrn::deserialization_packet xrt::drivers::wivrn::TCP::receive_ra
|
||||
|
||||
void xrt::drivers::wivrn::TCP::send_raw(const std::vector<std::span<uint8_t>> & spans)
|
||||
{
|
||||
std::vector<iovec> iovecs;
|
||||
thread_local std::vector<iovec> iovecs;
|
||||
iovecs.clear();
|
||||
|
||||
uint16_t size = 0;
|
||||
iovecs.emplace_back(&size, sizeof(size));
|
||||
|
||||
Reference in New Issue
Block a user