Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
63a7b5ee
Commit
63a7b5ee
authored
Oct 26, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid iterating types twice during message load
parent
d6bc6cc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
libcaf_core/caf/detail/meta_object.hpp
libcaf_core/caf/detail/meta_object.hpp
+4
-0
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+8
-10
No files found.
libcaf_core/caf/detail/meta_object.hpp
View file @
63a7b5ee
...
...
@@ -65,6 +65,10 @@ struct meta_object {
void
(
*
stringify
)(
std
::
string
&
,
const
void
*
);
};
inline
bool
valid
(
const
meta_object
&
obj
)
{
return
!
obj
.
type_name
.
empty
();
}
/// Returns the global storage for all meta objects. The ::type_id of an object
/// is the index for accessing the corresonding meta object.
CAF_CORE_EXPORT
span
<
const
meta_object
>
global_meta_objects
();
...
...
libcaf_core/src/message.cpp
View file @
63a7b5ee
...
...
@@ -73,22 +73,21 @@ bool load_data(Deserializer& source, message::data_ptr& data) {
&&
source
.
end_field
()
//
&&
source
.
end_object
();
}
auto
gmos
=
detail
::
global_meta_objects
();
size_t
data_size
=
0
;
detail
::
type_id_list_builder
ids
;
ids
.
reserve
(
msg_size
);
for
(
size_t
i
=
0
;
i
<
msg_size
;
++
i
)
{
type_id_t
id
=
0
;
GUARDED
(
source
.
value
(
id
));
ids
.
push_back
(
id
);
}
GUARDED
(
source
.
end_sequence
());
CAF_ASSERT
(
ids
.
size
()
==
msg_size
);
size_t
data_size
=
0
;
for
(
auto
id
:
ids
)
{
if
(
auto
meta_obj
=
detail
::
global_meta_object
(
id
))
data_size
+=
meta_obj
->
padded_size
;
else
if
(
id
<
gmos
.
size
()
&&
valid
(
gmos
[
id
]))
{
ids
.
push_back
(
id
);
data_size
+=
gmos
[
id
].
padded_size
;
}
else
{
STOP
(
sec
::
unknown_type
);
}
}
GUARDED
(
source
.
end_sequence
());
intrusive_ptr
<
detail
::
message_data
>
ptr
;
if
(
auto
vptr
=
malloc
(
sizeof
(
detail
::
message_data
)
+
data_size
))
{
// We don't need to worry about exceptions here: the message_data
...
...
@@ -99,7 +98,6 @@ bool load_data(Deserializer& source, message::data_ptr& data) {
}
auto
pos
=
ptr
->
storage
();
auto
types
=
ptr
->
types
();
auto
gmos
=
detail
::
global_meta_objects
();
GUARDED
(
source
.
begin_field
(
"values"
));
GUARDED
(
source
.
begin_tuple
(
msg_size
));
for
(
size_t
i
=
0
;
i
<
msg_size
;
++
i
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment