-
Notifications
You must be signed in to change notification settings - Fork 38.7k
net: simplify the call to vProcessMsg.splice() #26888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Could apply the same simplifcation to ConnmanTestMsg::NodeReceiveMsgBytes (in ./src/test/util/net.cpp)?
At the time when ```cpp pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg, pnode->vRecvMsg.begin(), it); ``` is called, `it` is certainly `pnode->vRecvMsg.end()` which makes the call equivalent to: ```cpp pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg, pnode->vRecvMsg.begin(), pnode->vRecvMsg.end()); ``` which is equivalent to: ```cpp pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg); ``` Thus, use the latter. Further, maybe irrelevant, but the latter has constant complexity while the original code is `O(length of vRecvMsg)`.
f58fe9c to
dfc01cc
Compare
|
Good catch, done! |
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-review ACK dfc01cc
|
Looks like this was made superfluous in 6294ecd |
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review ACK dfc01cc 🐑
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK dfc01ccd73e1f12698278d467c241f398da9fc7d 🐑
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjVGgv/Qo2DWDrtuhClKV9XUnELE8lGhcBjyxWGWlgWnW8XgD3q+GwQy0/lM0N8
DauZKO2j+4EzqBu/zjZdGtKOjTHs5dfErbESwI2JyUIDRwDJ6R+SLOzcnqeIxUTl
NSvJzvAPDfwXawgG+8xYGhlGG1JuZkb6qqeXXT3sYz71FoodKY32F3dwknFRgUHa
NlqlJcFkf8MyQN0pAknGhbf1EU1QnQ1ThMobdiSpXn5GofFaxJ/HXBOSitdhbpIF
A3urTWbWkIaDghLcl1a7e7nC5yw/aOuLx5KjMz7AE7C3tu1zA3viAbokhdlKAFhC
3Eh6RUULHv7AYi/kdCJWs26TI609eMEYCOFrbiFGZCftAR/DFoxQRzBS1sEVp0ps
eSZC7LRck0p8K/HPdZd1/+c58IfCgG8SfyjQpaywXXSExak/9AzHilGXiSmMGIGI
Zk3W5PZd0U1Aru3xUdbsbHQdgZdPGfEHV4lWXRhz7u3fzd6AQuBnieNcnEz/CWhZ
L18MDwXc
=W9U9
-----END PGP SIGNATURE-----
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Light review ACK dfc01cc
dfc01cc net: simplify the call to vProcessMsg.splice() (Vasil Dimov) Pull request description: At the time when ```cpp pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg, pnode->vRecvMsg.begin(), it); ``` is called, `it` is certainly `pnode->vRecvMsg.end()` which makes the call equivalent to: ```cpp pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg, pnode->vRecvMsg.begin(), pnode->vRecvMsg.end()); ``` which is equivalent to: ```cpp pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg); ``` Thus, use the latter. Further, maybe irrelevant, but the latter has constant complexity while the original code is `O(length of vRecvMsg)`. ACKs for top commit: theStack: Code-review ACK dfc01cc MarcoFalke: review ACK dfc01cc 🐑 jonatack: Light review ACK dfc01cc Tree-SHA512: 9f4eb61d1caf4af9a61ba2f54b915fcfe406db62c58ab1ec42f736505b6792e9379a83d0458d6cc04f289edcec070b7c962f94a920ab51701c3cab103152866f
At the time when
is called,
itis certainlypnode->vRecvMsg.end()which makes the call equivalent to:which is equivalent to:
Thus, use the latter. Further, maybe irrelevant, but the latter has constant complexity while the original code is
O(length of vRecvMsg).