HomePhabricator

refactor: replace (sizeof(a)/sizeof(a[0])) with C++17 std::size

Description

refactor: replace (sizeof(a)/sizeof(a[0])) with C++17 std::size

Summary:

refactor: iterate arrays via C++11 range-based for loops if idx is not needed

refactor: init vectors via std::{begin,end} to avoid pointer arithmetic

refactor: replace sizeof(a)/sizeof(a[0]) by std::size (C++17)

Removes the macro ARRAYLEN and also substitutes all other uses of the same
"sizeof(a)/sizeof(a[0])" pattern by std::size, available since C++17.

This is a backport of core#20429 and one commit from core#20245
https://github.com/bitcoin/bitcoin/pull/20245/commits/fa3967efdb07f1d22372f4ee2e602ea1fad04a57

The commit from core#20245 is doing the same thing as core#20249, and is unrelated to the rest of its PR, so the partial backport will not cause any issue.

Test Plan: ninja all check-all bitcoin-bench

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
Sebastian Falbesoner <sebastian.falbesoner@gmail.com>Authored on Nov 20 2020, 00:01
PiRKCommitted on Mar 10 2022, 09:02
PiRKPushed on Mar 10 2022, 09:02
Reviewer
Restricted Project
Differential Revision
D11140: refactor: replace (sizeof(a)/sizeof(a[0])) with C++17 std::size
Parents
rABCab711d137806: [Cashtab] Webpack upgrade part 2, ejecting create react app
Branches
Unknown
Tags
Unknown