[Trivial] Do not shadow local variable, cleanup #8449

pull paveljanik wants to merge 2 commits into bitcoin:master from paveljanik:20160803_shadow_blockencodings changing 2 files +4 −5
  1. paveljanik commented at 5:50 pm on August 3, 2016: contributor

    I was not available when #8068 was merged, sorry for late fix.

    This limits the scope of local variable, unifies for cycles used and as a side effect/bonus, fixes three instances of -Wshadow warnings ;-)

    For the reference, fixed warning is:

    0./blockencodings.h:56:25: warning: declaration shadows a local variable [-Wshadow]
    1            for (size_t i = 0; i < indexes.size(); i++) {
    2                        ^
    3./blockencodings.h:43:20: note: previous declaration is here
    4            size_t i = 0;
    5                   ^
    

    For more details, see #8105.

  2. in src/blockencodings.h: in 329680e6d4 outdated
    39@@ -40,10 +40,9 @@ class BlockTransactionsRequest {
    40         uint64_t indexes_size = (uint64_t)indexes.size();
    41         READWRITE(COMPACTSIZE(indexes_size));
    42         if (ser_action.ForRead()) {
    43-            size_t i = 0;
    44             while (indexes.size() < indexes_size) {
    45                 indexes.resize(std::min((uint64_t)(1000 + indexes.size()), indexes_size));
    46-                for (; i < indexes.size(); i++) {
    47+                for (size_t i = 0; i < indexes.size(); i++) {
    


    MarcoFalke commented at 6:05 pm on August 3, 2016:
    I think the initial design is on purpose. You are changing it such that the performance drops.

    paveljanik commented at 6:24 pm on August 3, 2016:
    If it is the case (I doubt it), why the exactly same code is a few lines below, i is not moved up and shared?

    MarcoFalke commented at 8:00 pm on August 3, 2016:
    Change this occurrence to j? Maybe it would help to combine such changes in a single pull?
  3. paveljanik commented at 6:24 pm on August 3, 2016: contributor
    @TheBlueMatt Can you please review this?
  4. Do not shadow local variable, cleanup cce3024c23
  5. paveljanik force-pushed on Aug 3, 2016
  6. jonasschnelli added the label Refactoring on Aug 4, 2016
  7. Remove redundand (and shadowing) declaration a159f25e19
  8. paveljanik commented at 6:05 pm on August 5, 2016: contributor
    Added one related commit - redundant declaration.
  9. MarcoFalke commented at 6:15 pm on August 5, 2016: member
    Instead of renaming two vars in small scopes you could just rename the one in the large scope?
  10. paveljanik commented at 6:31 pm on August 5, 2016: contributor
    Yes, I thought about it too. But then the question would be “Why j before i” ;-) I found this a bit more readable.
  11. sipa commented at 11:46 am on August 23, 2016: member
    utACK a159f25e19b8d921e30742f5ba87ef12803d991d
  12. paveljanik commented at 12:38 pm on August 24, 2016: contributor
    more ACKs please, this is trivial PR.
  13. MarcoFalke commented at 12:47 pm on August 24, 2016: member
    utACK a159f25
  14. laanwj commented at 10:23 am on September 2, 2016: member
    bitcoind for 5c7a5e1 and a159f25 matches, ACK a159f25
  15. laanwj merged this on Sep 2, 2016
  16. laanwj closed this on Sep 2, 2016

  17. laanwj referenced this in commit 381d0ddc8a on Sep 2, 2016
  18. gladcow referenced this in commit 99cea6454c on Mar 2, 2018
  19. gladcow referenced this in commit 7e826d7e8f on Mar 13, 2018
  20. gladcow referenced this in commit ffa39052d9 on Mar 14, 2018
  21. gladcow referenced this in commit f838e15fcc on Mar 15, 2018
  22. gladcow referenced this in commit e17895eb5c on Mar 15, 2018
  23. gladcow referenced this in commit b8c3aa7810 on Mar 24, 2018
  24. gladcow referenced this in commit 63c33e210d on Apr 4, 2018
  25. UdjinM6 referenced this in commit bc45a2f87a on Apr 11, 2018
  26. andvgal referenced this in commit fd5c50bc2b on Jan 6, 2019
  27. CryptoCentric referenced this in commit dd3fd51204 on Feb 28, 2019
  28. MarcoFalke locked this on Sep 8, 2021

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: 2024-12-19 06:12 UTC

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