Make WriteDelta/ReadDelta write/read 1-byte valeus directly instead of using varint differences
This commit is contained in:
parent
bdd2e2eefc
commit
c458fab429
@ -127,7 +127,14 @@ inline bool ReadRGB(InMessage& msg, glm::vec3& color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DELTA
|
// 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)
|
inline void WriteDelta(OutMessage& msg, T previous, T current)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T) <= 4);
|
static_assert(sizeof(T) <= 4);
|
||||||
@ -146,7 +153,14 @@ inline void WriteDelta(OutMessage& msg, T current, T previous)
|
|||||||
WriteDelta(msg, previous.value, current.value);
|
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)
|
inline bool ReadDelta(InMessage& msg, T previous, T& current)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T) <= 4);
|
static_assert(sizeof(T) <= 4);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user