Skip to content

Commit 9482834

Browse files
committed
chore: remove unneeded overloads
1 parent 10d36d5 commit 9482834

File tree

1 file changed

+12
-86
lines changed

1 file changed

+12
-86
lines changed

ecsact/runtime/serialize.hh

Lines changed: 12 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace ecsact {
1616
* @returns serialized action or component bytes
1717
*/
1818
template<typename T>
19+
requires(!std::is_same_v<std::remove_cvref_t<T>, ecsact_component> &&
20+
!std::is_same_v<std::remove_cvref_t<T>, ecsact_action>)
1921
ECSACT_ALWAYS_INLINE auto serialize( //
2022
const T& component_or_action
2123
) -> std::vector<std::byte> {
@@ -55,71 +57,20 @@ ECSACT_ALWAYS_INLINE auto serialize( //
5557
* fn are passed in to work around various linking configurations.
5658
* @returns serialized action bytes
5759
*/
58-
ECSACT_ALWAYS_INLINE auto serialize(
59-
const ecsact_component& component,
60-
decltype(ecsact_serialize_component_size) size_fn,
61-
decltype(ecsact_serialize_component) serialize_fn
60+
ECSACT_ALWAYS_INLINE auto serialize( //
61+
const ecsact_component& component
6262
) -> std::vector<std::byte> {
6363
std::vector<std::byte> out_component;
64-
out_component.resize(size_fn(component.component_id));
64+
out_component.resize(ecsact_serialize_component_size(component.component_id));
6565

66-
serialize_fn(
66+
ecsact_serialize_component(
6767
component.component_id,
6868
component.component_data,
6969
reinterpret_cast<uint8_t*>(out_component.data())
7070
);
7171
return out_component;
7272
}
7373

74-
/**
75-
* Serializes an ecsact_component when the type is unknown.
76-
* @returns serialized action bytes
77-
*/
78-
ECSACT_ALWAYS_INLINE auto serialize( //
79-
const ecsact_component& component
80-
) -> std::vector<std::byte> {
81-
return serialize(
82-
component,
83-
ecsact_serialize_component_size,
84-
ecsact_serialize_component
85-
);
86-
}
87-
88-
/**
89-
* Serializes an ecsact_action when the type is unknown. Size and serialize
90-
* fn are passed in to work around various linking configurations.
91-
* @returns serialized component bytes
92-
*/
93-
ECSACT_ALWAYS_INLINE auto serialize(
94-
const ecsact_action& action,
95-
decltype(ecsact_serialize_action_size) size_fn,
96-
decltype(ecsact_serialize_action) serialize_fn
97-
) -> std::vector<std::byte> {
98-
std::vector<std::byte> out_action;
99-
out_action.resize(size_fn(action.action_id));
100-
101-
serialize_fn(
102-
action.action_id,
103-
action.action_data,
104-
reinterpret_cast<uint8_t*>(out_action.data())
105-
);
106-
return out_action;
107-
}
108-
109-
/**
110-
* Serializes an ecsact_action when the type is unknown.
111-
* @returns serialized component bytes
112-
*/
113-
ECSACT_ALWAYS_INLINE auto serialize( //
114-
const ecsact_action& action
115-
) -> std::vector<std::byte> {
116-
return serialize(
117-
action,
118-
ecsact_serialize_action_size,
119-
ecsact_serialize_action
120-
);
121-
}
122-
12374
/**
12475
* Calls `ecsact_deserialize_action` or `ecsact_deserialize_component` based on
12576
* the type of @tp T.
@@ -198,14 +149,13 @@ ECSACT_ALWAYS_INLINE auto deserialize(
198149
* @returns an ecsact_action
199150
*/
200151
ECSACT_ALWAYS_INLINE auto deserialize(
201-
const ecsact_action_id& id,
202-
std::vector<std::byte>& serialized_action,
203-
decltype(ecsact_deserialize_action) deserialize_fn
152+
const ecsact_action_id& id,
153+
std::vector<std::byte>& serialized_action
204154
) -> std::vector<std::byte> {
205155
std::vector<std::byte> action_data;
206156
action_data.resize(serialized_action.size());
207157

208-
deserialize_fn(
158+
ecsact_deserialize_action(
209159
id,
210160
reinterpret_cast<uint8_t*>(serialized_action.data()),
211161
action_data.data()
@@ -218,42 +168,18 @@ ECSACT_ALWAYS_INLINE auto deserialize(
218168
* @returns an ecsact_action
219169
*/
220170
ECSACT_ALWAYS_INLINE auto deserialize(
221-
const ecsact_action_id& id,
222-
std::vector<std::byte>& serialized_action
223-
) -> std::vector<std::byte> {
224-
return deserialize(id, serialized_action, &ecsact_deserialize_action);
225-
}
226-
227-
/**
228-
* Deserializes an ecsact_component when the type is unknown.
229-
* @returns an ecsact_action
230-
*/
231-
ECSACT_ALWAYS_INLINE auto deserialize(
232-
const ecsact_component_id& id,
233-
std::vector<std::byte>& serialized_component,
234-
decltype(ecsact_deserialize_component) deserialize_fn
171+
const ecsact_component_id& id,
172+
std::vector<std::byte>& serialized_component
235173
) -> std::vector<std::byte> {
236174
std::vector<std::byte> component_data;
237175
component_data.resize(serialized_component.size());
238176

239-
deserialize_fn(
177+
ecsact_deserialize_component(
240178
id,
241179
reinterpret_cast<uint8_t*>(serialized_component.data()),
242180
component_data.data()
243181
);
244182
return component_data;
245183
}
246184

247-
/**
248-
* Deserializes an ecsact_component when the type is unknown. The deserialize
249-
* function is passed in to work around various linker configurations.
250-
* @returns an ecsact_component_id
251-
*/
252-
ECSACT_ALWAYS_INLINE auto deserialize(
253-
const ecsact_component_id& id,
254-
std::vector<std::byte>& serialized_component
255-
) -> std::vector<std::byte> {
256-
return deserialize(id, serialized_component, ecsact_deserialize_component);
257-
}
258-
259185
} // namespace ecsact

0 commit comments

Comments
 (0)