Using C++20 [[unlikely]] here would be excessive micro-optimization

This commit is contained in:
Rangi42
2024-12-23 14:14:10 -05:00
parent 22838ce2d8
commit 151f83db6d

View File

@@ -30,13 +30,11 @@ static std::vector<std::vector<FileStackNode>> nodes;
// Helper functions for reading object files // Helper functions for reading object files
// Internal, DO NOT USE. // For internal use only by `tryReadLong` and `tryGetc`!
// For helper wrapper macros defined below, such as `tryReadLong`
#define tryRead(func, type, errval, vartype, var, file, ...) \ #define tryRead(func, type, errval, vartype, var, file, ...) \
do { \ do { \
FILE *tmpFile = file; \ FILE *tmpFile = file; \
type tmpVal = func(tmpFile); \ type tmpVal = func(tmpFile); \
/* TODO: maybe mark the condition as `unlikely`; how to do that portably? */ \
if (tmpVal == (errval)) { \ if (tmpVal == (errval)) { \
errx(__VA_ARGS__, feof(tmpFile) ? "Unexpected end of file" : strerror(errno)); \ errx(__VA_ARGS__, feof(tmpFile) ? "Unexpected end of file" : strerror(errno)); \
} \ } \