bitcoin icon indicating copy to clipboard operation
bitcoin copied to clipboard

Reduce usage of auto in line with new recommendation

Open ajtowns opened this issue 7 years ago • 3 comments

Quick patch that removes a bunch of "auto" usage for your consideration. The auto->CKeyID change is against the merged segwit patches hence the fake rebase.

Remaining uses are:

  • ~70 in test/*
  • ~10 in bench/*
  • 123 range base for loops
  • 27 iterator assignements (begin, end, rbegin, rend, cbegin, cend, find, lower_bound, upper_bound)
  • 5 uses of std::pair: 2 emplace results, 1 insert result, 1 bech32::Decode result, and 1 dereference map iterator
  • 4 uses with boost::get for variant in keystore.cpp
  • 4 closures/lambdas
  • reverse_iterator.h template return values

ajtowns avatar Jan 11 '18 09:01 ajtowns

I dont think we ever do backwards-facing changes for style guidelines, no reason to start now?

TheBlueMatt avatar Jan 11 '18 16:01 TheBlueMatt

Usual reasons not to retroactively fix style stuff are:

  • it makes it hard to follow history (git blame just points to the reindent commit for every line in the file)
  • it makes it hard to do backports or requires active PRs to be rebased
  • there's not much practical benefit from the change

That's not the case here: they're just changing one line, so the impact on history is minimal; backports and PRs should barely be impacted, and making the type explicit makes it easier to understand the code so there is an immediate practical benefit... A few of those changes seem worthwhile even without the guideline. But your call.

ajtowns avatar Jan 11 '18 23:01 ajtowns

I mean the change itself seems fine, but the project is already inundated with a flood of cleanup fixes, so I'm not sure more is worth it. Feel free to PR upstream if you prefer.

TheBlueMatt avatar Jan 12 '18 00:01 TheBlueMatt