net: simplify the call to vProcessMsg.splice()#26888
Merged
Merged
Conversation
Contributor
|
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
reviewed
Jan 21, 2023
Contributor
theStack
left a comment
There was a problem hiding this comment.
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
Contributor
Author
|
Good catch, done! |
Member
|
Looks like this was made superfluous in 6294ecd |
maflcko
approved these changes
Jan 30, 2023
Member
maflcko
left a comment
There was a problem hiding this comment.
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
reviewed
Jan 30, 2023
sidhujag
pushed a commit
to syscoin/syscoin
that referenced
this pull request
Feb 1, 2023
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).