rust-bitcoin / rust-bitcoincore-rpc

Rust RPC client library for the Bitcoin Core JSON-RPC API.
340 stars 255 forks source link

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

Closed philipjonsen closed 2 months ago

philipjonsen commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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.)

I see! Just wanted to help out.