Skip to content

Commit

Permalink
Removed brute optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzicheng1987 committed May 28, 2024
1 parent 2088598 commit 18e1223
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions include/rfl/json/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,9 @@ Result<internal::wrap_in_rfl_array_t<T>> read(const std::string& _json_str) {
}
yyjson_val* root = yyjson_doc_get_root(doc);
const auto r = Reader();
if constexpr (std::is_class_v<T> && std::is_aggregate_v<T>) {
using ProcessorsType = Processors<Ps...>;
alignas(T) unsigned char buf[sizeof(T)];
auto ptr = reinterpret_cast<T*>(buf);
auto view = ProcessorsType::template process<T>(to_view(*ptr));
using ViewType = std::remove_cvref_t<decltype(view)>;
const auto err = Parser<ViewType, ProcessorsType>::read_view(
r, InputVarType(root), &view);
yyjson_doc_free(doc);
if (err) [[unlikely]] {
return *err;
}
return std::move(*ptr);
} else {
auto res = Parser<T, Processors<Ps...>>::read(r, InputVarType(root));
yyjson_doc_free(doc);
return res;
}
auto res = Parser<T, Processors<Ps...>>::read(r, InputVarType(root));
yyjson_doc_free(doc);
return res;
}

/// Parses an object from a stringstream.
Expand Down

0 comments on commit 18e1223

Please sign in to comment.