[bitcoin/bitcoin] refactor: add benchmarks and speed up bech32 encoder (#13586)

kallewoof commented on this pull request.

> @@ -147,12 +148,14 @@ namespace bech32
std::string Encode(const std::string& hrp, const data& values) {
data checksum = CreateChecksum(hrp, values);
data combined = Cat(values, checksum);
— std::string ret = hrp + ‘1’;
— ret.reserve(ret.size() + combined.size());
+ char ret[91];
+ memcpy(ret, hrp.c_str(), hrp.size());

I knew you’d say that. Added length check and updated benchmark results in OP. Still improvement.

Добавить комментарий