Skip to content

Commit acc9e3e

Browse files
committed
Inline scalar and vector element parsing helpers
1 parent eb82ef6 commit acc9e3e

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎include/rfl/parsing/ParserBasicType.hpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "../always_false.hpp"
99
#include "../enums.hpp"
1010
#include "../from_named_tuple.hpp"
11+
#include "../internal/always_inline.hpp"
1112
#include "../internal/has_default_val_v.hpp"
1213
#include "../internal/has_reflection_method_v.hpp"
1314
#include "../internal/has_reflection_type_v.hpp"
@@ -47,7 +48,8 @@ struct ParserBasicType {
4748
* @param _var The input variable to read from.
4849
* @return A Result containing the parsed value or an error.
4950
*/
50-
static Result<T> read(const R& _r, const InputVarType& _var) noexcept {
51+
static RFL_ALWAYS_INLINE Result<T> read(const R& _r,
52+
const InputVarType& _var) noexcept {
5153
return _r.template to_basic_type<std::remove_cvref_t<T>>(_var);
5254
}
5355

‎include/rfl/parsing/VectorReader.hpp‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@ class VectorReader {
5353
* @return An optional error.
5454
*/
5555
RFL_ALWAYS_INLINE std::optional<Error> read(const InputVarType& _var) const {
56-
const auto parse = [this](const InputVarType& _var) {
57-
if constexpr (is_map_like_v<VecType>) {
58-
return get_pair(_var);
59-
} else {
60-
return Parser<R, W, std::remove_cvref_t<T>, ProcessorsType>::read(*r_,
61-
_var);
62-
}
63-
};
64-
6556
const auto insert = [this](auto&& _var) -> std::optional<Error> {
6657
if constexpr (is_map_like_v<VecType> || is_set_like_v<VecType>) {
6758
vec_->insert(std::move(_var));
@@ -85,6 +76,14 @@ class VectorReader {
8576
}
8677

8778
private:
79+
RFL_ALWAYS_INLINE auto parse(const InputVarType& _var) const {
80+
if constexpr (is_map_like_v<VecType>) {
81+
return get_pair(_var);
82+
} else {
83+
return Parser<R, W, std::remove_cvref_t<T>, ProcessorsType>::read(*r_, _var);
84+
}
85+
}
86+
8887
auto get_pair(const auto& _var) const {
8988
using K = std::remove_cvref_t<typename T::first_type>;
9089
using V = std::remove_cvref_t<typename T::second_type>;

0 commit comments

Comments
 (0)