Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
a4aceb27
Commit
a4aceb27
authored
7 years ago
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: use of std::map::insert is inefficient
Solution: use std::map::emplace instead, where available
parent
07eb52cb
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
18 deletions
+17
-18
ctx.cpp
src/ctx.cpp
+3
-2
mechanism.cpp
src/mechanism.cpp
+6
-8
pgm_receiver.cpp
src/pgm_receiver.cpp
+1
-1
radio.cpp
src/radio.cpp
+1
-1
server.cpp
src/server.cpp
+1
-1
socket_base.cpp
src/socket_base.cpp
+2
-2
stream_engine.cpp
src/stream_engine.cpp
+3
-3
No files found.
src/ctx.cpp
View file @
a4aceb27
...
...
@@ -451,7 +451,8 @@ int zmq::ctx_t::register_endpoint (const char *addr_,
{
scoped_lock_t
locker
(
endpoints_sync
);
const
bool
inserted
=
endpoints
.
insert
(
endpoints_t
::
value_type
(
std
::
string
(
addr_
),
endpoint_
)).
second
;
const
bool
inserted
=
endpoints
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
addr_
,
endpoint_
).
second
;
if
(
!
inserted
)
{
errno
=
EADDRINUSE
;
return
-
1
;
...
...
@@ -524,7 +525,7 @@ void zmq::ctx_t::pend_connection (const std::string &addr_,
if
(
it
==
endpoints
.
end
())
{
// Still no bind.
endpoint_
.
socket
->
inc_seqnum
();
pending_connections
.
insert
(
pending_connections_t
::
value_type
(
addr_
,
pending_connection
)
);
pending_connections
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
addr_
,
pending_connection
);
}
else
{
// Bind has happened in the mean time, connect directly
connect_inproc_sockets
(
it
->
second
.
socket
,
it
->
second
.
options
,
pending_connection
,
connect_side
);
...
...
This diff is collapsed.
Click to expand it.
src/mechanism.cpp
View file @
a4aceb27
...
...
@@ -62,8 +62,8 @@ void zmq::mechanism_t::peer_routing_id (msg_t *msg_)
void
zmq
::
mechanism_t
::
set_user_id
(
const
void
*
data_
,
size_t
size_
)
{
user_id
.
set
(
static_cast
<
const
unsigned
char
*>
(
data_
),
size_
);
zap_properties
.
insert
(
metadata_t
::
dict_t
::
value_type
(
ZMQ_MSG_PROPERTY_USER_ID
,
std
::
string
((
char
*
)
data_
,
size_
))
)
;
zap_properties
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
ZMQ_MSG_PROPERTY_USER_ID
,
std
::
string
((
char
*
)
data_
,
size_
));
}
const
zmq
::
blob_t
&
zmq
::
mechanism_t
::
get_user_id
()
const
...
...
@@ -218,13 +218,11 @@ int zmq::mechanism_t::parse_metadata (const unsigned char *ptr_,
return
-
1
;
}
if
(
zap_flag
)
zap_properties
.
insert
(
metadata_t
::
dict_t
::
value_type
(
name
,
std
::
string
((
char
*
)
value
,
value_length
)));
zap_properties
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
name
,
std
::
string
((
char
*
)
value
,
value_length
));
else
zmtp_properties
.
insert
(
metadata_t
::
dict_t
::
value_type
(
name
,
std
::
string
((
char
*
)
value
,
value_length
)));
zmtp_properties
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
name
,
std
::
string
((
char
*
)
value
,
value_length
));
}
if
(
bytes_left
>
0
)
{
errno
=
EPROTO
;
...
...
This diff is collapsed.
Click to expand it.
src/pgm_receiver.cpp
View file @
a4aceb27
...
...
@@ -206,7 +206,7 @@ void zmq::pgm_receiver_t::in_event ()
// New peer. Add it to the list of know but unjoint peers.
if
(
it
==
peers
.
end
())
{
peer_info_t
peer_info
=
{
false
,
NULL
};
it
=
peers
.
insert
(
peers_t
::
value_type
(
*
tsi
,
peer_info
)
).
first
;
it
=
peers
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
*
tsi
,
peer_info
).
first
;
}
insize
=
static_cast
<
size_t
>
(
received
);
...
...
This diff is collapsed.
Click to expand it.
src/radio.cpp
View file @
a4aceb27
...
...
@@ -76,7 +76,7 @@ void zmq::radio_t::xread_activated (pipe_t *pipe_)
std
::
string
group
=
std
::
string
(
msg
.
group
());
if
(
msg
.
is_join
())
subscriptions
.
insert
(
subscriptions_t
::
value_type
(
group
,
pipe_
)
);
subscriptions
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
ZMQ_MOVE
(
group
),
pipe_
);
else
{
std
::
pair
<
subscriptions_t
::
iterator
,
subscriptions_t
::
iterator
>
range
=
subscriptions
.
equal_range
(
group
);
...
...
This diff is collapsed.
Click to expand it.
src/server.cpp
View file @
a4aceb27
...
...
@@ -61,7 +61,7 @@ void zmq::server_t::xattach_pipe (pipe_t *pipe_, bool subscribe_to_all_)
pipe_
->
set_server_socket_routing_id
(
routing_id
);
// Add the record into output pipes lookup table
outpipe_t
outpipe
=
{
pipe_
,
true
};
bool
ok
=
outpipes
.
insert
(
outpipes_t
::
value_type
(
routing_id
,
outpipe
)
).
second
;
bool
ok
=
outpipes
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
routing_id
,
outpipe
).
second
;
zmq_assert
(
ok
);
fq
.
attach
(
pipe_
);
...
...
This diff is collapsed.
Click to expand it.
src/socket_base.cpp
View file @
a4aceb27
...
...
@@ -817,7 +817,7 @@ int zmq::socket_base_t::connect (const char *addr_)
last_endpoint
.
assign
(
addr_
);
// remember inproc connections for disconnect
inprocs
.
insert
(
inprocs_t
::
value_type
(
std
::
string
(
addr_
),
new_pipes
[
0
])
);
inprocs
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
addr_
,
new_pipes
[
0
]
);
options
.
connected
=
true
;
return
0
;
...
...
@@ -1004,7 +1004,7 @@ void zmq::socket_base_t::add_endpoint (const char *addr_, own_t *endpoint_, pipe
{
// Activate the session. Make it a child of this socket.
launch_child
(
endpoint_
);
endpoints
.
insert
(
endpoints_t
::
value_type
(
std
::
string
(
addr_
),
endpoint_pipe_t
(
endpoint_
,
pipe
)
));
endpoints
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
addr_
,
endpoint_pipe_t
(
endpoint_
,
pipe
));
}
int
zmq
::
socket_base_t
::
term_endpoint
(
const
char
*
addr_
)
...
...
This diff is collapsed.
Click to expand it.
src/stream_engine.cpp
View file @
a4aceb27
...
...
@@ -1010,14 +1010,14 @@ void zmq::stream_engine_t::set_handshake_timer ()
bool
zmq
::
stream_engine_t
::
init_properties
(
properties_t
&
properties
)
{
if
(
peer_address
.
empty
())
return
false
;
properties
.
insert
(
std
::
make_pair
(
ZMQ_MSG_PROPERTY_PEER_ADDRESS
,
peer_address
)
);
properties
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
ZMQ_MSG_PROPERTY_PEER_ADDRESS
,
peer_address
);
// Private property to support deprecated SRCFD
std
::
ostringstream
stream
;
stream
<<
(
int
)
s
;
std
::
string
fd_string
=
stream
.
str
();
properties
.
insert
(
std
::
make_pair
(
"__fd"
,
fd_string
));
properties
.
ZMQ_MAP_INSERT_OR_EMPLACE
(
"__fd"
,
ZMQ_MOVE
(
fd_string
));
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
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