Page MenuHomePhabricator

refactor: Replace &foo[0] with foo.data()
ClosedPublic

Authored by PiRK on Nov 21 2023, 13:53.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC30bff8486a50: refactor: Replace &foo[0] with foo.data()
Summary

Rationales from the PR description:

  • In CSignatureCache::ComputeEntry, change the way a vector pointer is resolved to prevent invoking undefined behavior if the vector is empty.
  • Sometimes alternative code without any raw data pointers is easier to read (refer to the respective commit message for details)
  • If the raw data pointer is needed, foo.data() should be preferred, as pointed out in the developer notes.

This is a backport of core#21817

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Nov 21 2023, 13:53

additional rationale: this is a dependency of a dependency of another PR touching code that is moved around and touched by other more important backports (in net_processing.cpp)

Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/wallet/crypter.cpp
143

funny

This revision is now accepted and ready to land.Nov 21 2023, 14:56