HomePhabricator

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

Description

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

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14826

Details

Provenance
Guido Vranken <guidovranken@gmail.com>Authored on Apr 26 2021, 20:08
PiRKCommitted on Nov 21 2023, 16:22
PiRKPushed on Nov 21 2023, 16:22
Reviewer
Restricted Project
Differential Revision
D14826: refactor: Replace &foo[0] with foo.data()
Parents
rABC8270010d754c: [Cashtab] app.js format improvements
Branches
Unknown
Tags
Unknown