Skip to content

Commit

Permalink
inline
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed May 15, 2024
1 parent cf1427f commit adabfaf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions iguana/pb_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@ constexpr IGUANA_INLINE size_t variant_intergal_size(U value) {
}

template <typename F, size_t... I>
constexpr void for_each_n(F&& f, std::index_sequence<I...>) {
IGUANA_INLINE constexpr void for_each_n(F&& f, std::index_sequence<I...>) {
(std::forward<F>(f)(std::integral_constant<size_t, I>{}), ...);
}

// cache the size of reflection type
template <typename T>
auto& get_set_size_cache(T& t) {
IGUANA_INLINE auto& get_set_size_cache(T& t) {
static std::map<size_t, size_t> cache;
return cache[reinterpret_cast<size_t>(&t)];
}
Expand Down
4 changes: 1 addition & 3 deletions iguana/pb_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ IGUANA_INLINE void to_pb_impl(Type&& t, It&& it) {
if (len == 0)
IGUANA_UNLIKELY { return; }
}
constexpr auto tuple = get_members_tuple<T>();
static constexpr auto tuple = get_members_tuple<T>();
constexpr size_t SIZE = std::tuple_size_v<std::decay_t<decltype(tuple)>>;
for_each_n(
[&t, &it](auto i) IGUANA__INLINE_LAMBDA {
constexpr auto tuple = get_members_tuple<T>();
using field_type =
std::tuple_element_t<decltype(i)::value,
std::decay_t<decltype(tuple)>>;
Expand Down Expand Up @@ -212,6 +211,5 @@ IGUANA_INLINE void to_pb(T& t, Stream& out) {
auto byte_len = detail::pb_key_value_size<0>(t);
detail::resize(out, byte_len);
detail::to_pb_impl<0>(t, &out[0]);
// TODO: end with '\0' ?
}
} // namespace iguana

0 comments on commit adabfaf

Please sign in to comment.