Marked unlikely code paths as [[unlikely]]

This commit is contained in:
Vladyslav Baranovskyi
2024-10-10 15:42:41 +03:00
parent cc20a1fb3b
commit b0b966aab7

View File

@@ -88,20 +88,20 @@ namespace OpenVulkano
pnmHeader.ascii = val < 4; pnmHeader.ascii = val < 4;
pnmHeader.color = static_cast<ColorMode>(val - 3); pnmHeader.color = static_cast<ColorMode>(val - 3);
if (!(inStream >> pnmHeader.width >> pnmHeader.height)) if (!(inStream >> pnmHeader.width >> pnmHeader.height)) [[unlikely]]
{ {
throw std::runtime_error("Malformed PNM header: Unable to read width and height!"); throw std::runtime_error("Malformed PNM header: Unable to read width and height!");
} }
if (pnmHeader.width == 0 || pnmHeader.height == 0) if (pnmHeader.width == 0 || pnmHeader.height == 0) [[unlikely]]
{ {
throw std::runtime_error("Malformed PNM header: Width and height must be positive!"); throw std::runtime_error("Malformed PNM header: Width and height must be positive!");
} }
if (!(inStream >> pnmHeader.maxValue)) if (!(inStream >> pnmHeader.maxValue)) [[unlikely]]
{ {
throw std::runtime_error("Malformed PNM header: Unable to read maxValue!"); throw std::runtime_error("Malformed PNM header: Unable to read maxValue!");
} }
if (pnmHeader.maxValue == 0 || pnmHeader.maxValue > 65535) if (pnmHeader.maxValue == 0 || pnmHeader.maxValue > 65535) [[unlikely]]
{ {
throw std::runtime_error("Malformed PNM header: Invalid maxValue (must be between 1 and 65535)!"); throw std::runtime_error("Malformed PNM header: Invalid maxValue (must be between 1 and 65535)!");
} }