Core/PacketIO: Read directly into output variable for numeric ByteBuffer::operator>> overloads

This commit is contained in:
Shauren
2024-12-19 19:45:58 +01:00
parent 736836a3f5
commit 5a1fe84978
2 changed files with 10 additions and 10 deletions

View File

@@ -41,7 +41,7 @@ ByteBufferInvalidValueException::ByteBufferInvalidValueException(char const* typ
ByteBuffer& ByteBuffer::operator>>(float& value)
{
value = read<float>();
read(&value, 1);
if (!std::isfinite(value))
throw ByteBufferInvalidValueException("float", "infinity");
return *this;
@@ -49,7 +49,7 @@ ByteBuffer& ByteBuffer::operator>>(float& value)
ByteBuffer& ByteBuffer::operator>>(double& value)
{
value = read<double>();
read(&value, 1);
if (!std::isfinite(value))
throw ByteBufferInvalidValueException("double", "infinity");
return *this;