Skip to content

Found single-character string literal pattern RS-P1100 #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philipjonsen opened this issue Sep 19, 2024 · 2 comments
Closed

Found single-character string literal pattern RS-P1100 #370

philipjonsen opened this issue Sep 19, 2024 · 2 comments

Comments

@philipjonsen
Copy link

Can cause major performance issues.

Description

Certain str functions, such as .split() and .find() work on patterns that accept both string literals as well as characters. When using such functions, prefer chars over single-character string literals as they are more performant.

Replace the single-character string literal with a char.

Bad practice
let x = "hello, world";
x.find("o"); // single-character str

Recommended
let x = "hello, world";
x.find('o'); // use a char instead

https://github.com/rust-bitcoincore-rpc/blob/master/client/src/client.rs#L212-L212

@apoelstra
Copy link
Member

Appears to be some kind of broken bot. The issue in question can be found by clippy, and even if you fix the broken URL you will find that it does not apply to the file in question. (I believe it did prior to #252 nearly two years ago.)

@philipjonsen

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants