Make WriteDelta/ReadDelta write/read 1-byte valeus directly instead of using varint differences

This commit is contained in:
tovjemam 2026-02-11 20:47:39 +01:00
parent bdd2e2eefc
commit c458fab429

View File

@ -127,7 +127,14 @@ inline bool ReadRGB(InMessage& msg, glm::vec3& color)
}
// DELTA
template <std::unsigned_integral T>
template <std::unsigned_integral T> requires (sizeof(T) == 1)
inline void WriteDelta(OutMessage& msg, T previous, T current)
{
// 1 byte => just write current
msg.Write(current);
}
template <std::unsigned_integral T> requires (sizeof(T) > 1)
inline void WriteDelta(OutMessage& msg, T previous, T current)
{
static_assert(sizeof(T) <= 4);
@ -146,7 +153,14 @@ inline void WriteDelta(OutMessage& msg, T current, T previous)
WriteDelta(msg, previous.value, current.value);
}
template <std::unsigned_integral T>
template <std::unsigned_integral T> requires (sizeof(T) == 1)
inline bool ReadDelta(InMessage& msg, T previous, T& current)
{
// 1 byte => just read current
return msg.Read(current);
}
template <std::unsigned_integral T> requires (sizeof(T) > 1)
inline bool ReadDelta(InMessage& msg, T previous, T& current)
{
static_assert(sizeof(T) <= 4);