Page MenuHomePhabricator

Merge #12159: Use the character based overload for std::string::find.
ClosedPublic

Authored by nakihito on Jul 25 2019, 22:49.

Details

Summary

a73aab7 Use the character based overload for std::string::find. (Alin Rus)

Pull request description:

std::string::find has a character based overload as can be seen here
(4th oveload): http://www.cplusplus.com/reference/string/string/find/

Use that instead of constantly allocating temporary strings.

Tree-SHA512: dc7684b1551e6d779eb989e9a74363f9b978059a7c0f3db09d01744c7e6452961f9e671173265e71efff27afbcb80c0fe2c11b6dff2290e54a49193fa25a5679

Backport of Core PR12159
https://github.com/bitcoin/bitcoin/pull/12159/

Test Plan
make check

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Jul 25 2019, 22:49
deadalnix requested changes to this revision.Jul 25 2019, 23:43

There are 2 more instances in the codebase.

This revision now requires changes to proceed.Jul 25 2019, 23:43

There are 2 more instances in the codebase.

Could you point them out to me? The only other instance of std::string::find() I found was wallet.h line 619 size_t nSepPos = strComment.find("\0", 0, 1); and changing "\0" to '\0' does not compile.

nakihito requested review of this revision.Sep 9 2019, 18:25
deadalnix requested changes to this revision.Sep 11 2019, 12:18

I do not have these cases now. Grepping quickly it seems that wallet.h is the only remaining case now. In any case, considering you *KNOW* about it, why isn't it fixed after a month?

This revision now requires changes to proceed.Sep 11 2019, 12:18

Fixed remaining instance in wallet.h.

jasonbcox requested changes to this revision.Sep 11 2019, 20:26
jasonbcox added inline comments.
src/wallet/wallet.h
617 ↗(On Diff #11214)

pos is 0 by default. you can remove the second argument.

This revision now requires changes to proceed.Sep 11 2019, 20:26
This revision is now accepted and ready to land.Sep 12 2019, 20:20