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
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

nakihito created this revision.Jul 25 2019, 22:49
Owners added a reviewer: Restricted Owners Package.Jul 25 2019, 22:49
Herald added a reviewer: Restricted Project. · View Herald TranscriptJul 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
nakihito updated this revision to Diff 11214.Sep 11 2019, 18:27

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
nakihito updated this revision to Diff 11223.Sep 11 2019, 20:40

Fixed nit.

deadalnix accepted this revision.Sep 12 2019, 08:18
jasonbcox accepted this revision.Sep 12 2019, 20:20
This revision is now accepted and ready to land.Sep 12 2019, 20:20