The main theme of this refactor is to replace &foo[0]
with foo.data()
.
The first commit is taken from #21781 with the rationale:
- In CSignatureCache::ComputeEntryECDSA, change the way a vector pointer is resolved to prevent invoking undefined behavior if the vector is empty.
The other commits aim to remove all &foo[0]
, where foo
is any kind of byte representation. The rationale:
- 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 addresses the instances that have been missed in commit 592404f03f2b734351d734f0c9ca1fdce997321b, and https://github.com/bitcoin/bitcoin/pull/9804