Move magic enum to local and avoid allocation#144
Conversation
53d4a5a to
18cf0a9
Compare
| default: | ||
| throw std::logic_error("JsonWebSignatureAlgorithm::hashAlgorithm(): Invalid value " | ||
| + std::to_string(value)); | ||
| std::unreachable(); |
There was a problem hiding this comment.
I don’t think std::unreachable() is justified as it causes a segmentation fault. The optimization is insignificant compared to the cost, let's keep it defensive and revert to using an exception and remove noexcept even if the constructor validates values today. I'll undo these changes for now, we can discuss this further when your'e back from vacation.
There was a problem hiding this comment.
I see your point, but I disagree in this case. The constructor already validates the values, so this path should not be reachable.
The std::unreachable() is mainly there because compiler support (gcc) for exhaustive enum switch handling is limited, and adding a default case can hide missing enum cases in the future.
| target_compile_features(${PROJECT_NAME} | ||
| PUBLIC | ||
| cxx_std_20 | ||
| cxx_std_23 |
There was a problem hiding this comment.
No need to use cxx_std_23 when we drop std::unreachable(). I'll undo this for now.
WE2-1204, WE2-1057 Signed-off-by: Raul Metsma <raul@metsma.ee>
WE2-1204
Signed-off-by: Raul Metsma raul@metsma.ee