1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 20:47:46 +00:00

seq:reduce memory allocation during prefix search

This improvement eliminates extra memory allocations during the search
for 0x/0X prefixes in number strings.
This commit is contained in:
Alexander Shirokov 2024-12-11 14:28:46 +01:00
parent 5461a9781c
commit 3900fa91ba
No known key found for this signature in database
GPG key ID: 6020E4D7AFA8ECE7

View file

@ -341,7 +341,7 @@ impl FromStr for PreciseNumber {
// Check if the string seems to be in hexadecimal format.
//
// May be 0x123 or -0x123, so the index `i` may be either 0 or 1.
if let Some(i) = s.to_lowercase().find("0x") {
if let Some(i) = s.find("0x").or_else(|| s.find("0X")) {
if i <= 1 {
return parse_hexadecimal(s);
}