diff options
| author | bors <bors@rust-lang.org> | 2022-05-16 00:12:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-16 00:12:06 +0000 |
| commit | cdd74fc7b19805c65c7d6f759ec6871be1c38fce (patch) | |
| tree | 25888ebe2d05d5333acfe0edbee6072219cae606 | |
| parent | 42e1761c704f074b7b8c7ff8a7433acfd65d2ee9 (diff) | |
| parent | 26265319c7d04306ccdf60e50580e3778f5e9134 (diff) | |
| download | rust-cdd74fc7b19805c65c7d6f759ec6871be1c38fce.tar.gz rust-cdd74fc7b19805c65c7d6f759ec6871be1c38fce.zip | |
Auto merge of #97065 - gabriel-doriath-dohler:master, r=joshtriplett
Rename `eq_ignore_case` to `starts_with_ignore_case` The method doesn't test for equality. It tests if the object starts with a given byte array, so its name is confusing.
| -rw-r--r-- | library/core/src/num/dec2flt/common.rs | 2 | ||||
| -rw-r--r-- | library/core/src/num/dec2flt/parse.rs | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/library/core/src/num/dec2flt/common.rs b/library/core/src/num/dec2flt/common.rs index 247123737df..17957d7e770 100644 --- a/library/core/src/num/dec2flt/common.rs +++ b/library/core/src/num/dec2flt/common.rs @@ -36,7 +36,7 @@ pub(crate) trait ByteSlice: AsRef<[u8]> { } /// Check if self starts with u with a case-insensitive comparison. - fn eq_ignore_case(&self, u: &[u8]) -> bool { + fn starts_with_ignore_case(&self, u: &[u8]) -> bool { debug_assert!(self.as_ref().len() >= u.len()); let iter = self.as_ref().iter().zip(u.iter()); let d = iter.fold(0, |i, (&x, &y)| i | (x ^ y)); diff --git a/library/core/src/num/dec2flt/parse.rs b/library/core/src/num/dec2flt/parse.rs index fa677bf5123..1a90e0d206f 100644 --- a/library/core/src/num/dec2flt/parse.rs +++ b/library/core/src/num/dec2flt/parse.rs @@ -207,12 +207,12 @@ pub fn parse_number(s: &[u8], negative: bool) -> Option<Number> { /// Parse a partial representation of a special, non-finite float. fn parse_partial_inf_nan<F: RawFloat>(s: &[u8]) -> Option<(F, usize)> { fn parse_inf_rest(s: &[u8]) -> usize { - if s.len() >= 8 && s[3..].as_ref().eq_ignore_case(b"inity") { 8 } else { 3 } + if s.len() >= 8 && s[3..].as_ref().starts_with_ignore_case(b"inity") { 8 } else { 3 } } if s.len() >= 3 { - if s.eq_ignore_case(b"nan") { + if s.starts_with_ignore_case(b"nan") { return Some((F::NAN, 3)); - } else if s.eq_ignore_case(b"inf") { + } else if s.starts_with_ignore_case(b"inf") { return Some((F::INFINITY, parse_inf_rest(s))); } } |
