mirror of https://github.com/libAthena/athena.git
DNAYaml: Make use of if constexpr within NodeToVec()
Only the constexpr isDouble variable is tested within the conditional, so we can make use of if constexpr here.
This commit is contained in:
parent
120b3d1281
commit
e7f7867f32
|
@ -139,21 +139,23 @@ std::unique_ptr<YAMLNode> ValToNode(double val) {
|
|||
|
||||
template <typename RETURNTYPE>
|
||||
RETURNTYPE NodeToVec(const YAMLNode* node) {
|
||||
constexpr bool isDouble = std::is_same<RETURNTYPE, atVec2d>::value || std::is_same<RETURNTYPE, atVec3d>::value ||
|
||||
std::is_same<RETURNTYPE, atVec4d>::value;
|
||||
constexpr bool isDouble =
|
||||
std::is_same_v<RETURNTYPE, atVec2d> || std::is_same_v<RETURNTYPE, atVec3d> || std::is_same_v<RETURNTYPE, atVec4d>;
|
||||
RETURNTYPE retval = {};
|
||||
auto it = node->m_seqChildren.begin();
|
||||
simd_values<std::conditional_t<isDouble, double, float>> f;
|
||||
for (size_t i = 0; i < 4 && it != node->m_seqChildren.end(); ++i, ++it) {
|
||||
YAMLNode* snode = it->get();
|
||||
if (snode->m_type == YAML_SCALAR_NODE) {
|
||||
if (isDouble)
|
||||
if constexpr (isDouble) {
|
||||
f[i] = NodeToVal<double>(snode);
|
||||
else
|
||||
} else {
|
||||
f[i] = NodeToVal<float>(snode);
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
f[i] = 0.0;
|
||||
}
|
||||
}
|
||||
retval.simd.copy_from(f);
|
||||
return retval;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue