net: simplify the call to vProcessMsg.splice() #26888

pull vasild wants to merge 1 commits into bitcoin:master from vasild:simplify_vProcessMsg_splice changing 2 files +6 −8
  1. vasild commented at 1:52 PM on January 13, 2023: contributor

    At the time when

    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:

    pnode->vProcessMsg.splice(pnode->vProcessMsg.end(), pnode->vRecvMsg, pnode->vRecvMsg.begin(), pnode->vRecvMsg.end());
    

    which is equivalent to:

    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).

  2. DrahtBot commented at 1:52 PM on January 13, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK theStack, MarcoFalke, jonatack

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label P2P on Jan 13, 2023
  4. theStack commented at 3:51 PM on January 21, 2023: contributor

    Concept ACK

    Could apply the same simplifcation to ConnmanTestMsg::NodeReceiveMsgBytes (in ./src/test/util/net.cpp)?

  5. net: simplify the call to vProcessMsg.splice()
    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)`.
    dfc01ccd73
  6. vasild force-pushed on Jan 30, 2023
  7. vasild commented at 10:22 AM on January 30, 2023: contributor

    f58fe9cf9c...dfc01ccd73:

    Could apply the same simplifcation to ConnmanTestMsg::NodeReceiveMsgBytes

    Good catch, done!

  8. theStack approved
  9. theStack commented at 11:02 AM on January 30, 2023: contributor

    Code-review ACK dfc01ccd73e1f12698278d467c241f398da9fc7d

  10. maflcko commented at 4:09 PM on January 30, 2023: member

    Looks like this was made superfluous in 6294ecdb8bb4eb7049a18c721ee8cb4a53d80a06

  11. maflcko approved
  12. maflcko commented at 4:22 PM on January 30, 2023: member

    review ACK dfc01ccd73e1f12698278d467c241f398da9fc7d 🐑

    <details><summary>Show signature</summary>

    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-----
    

    </details>

  13. jonatack commented at 4:22 PM on January 30, 2023: contributor

    Light review ACK dfc01ccd73e1f12698278d467c241f398da9fc7d

  14. maflcko merged this on Feb 1, 2023
  15. maflcko closed this on Feb 1, 2023

  16. sidhujag referenced this in commit 28d84f84bd on Feb 1, 2023
  17. bitcoin locked this on Feb 1, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-25 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me