Skip to content

Commit

Permalink
Rollup merge of rust-lang#67237 - llogiq:improve-str, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Some small readability improvements
  • Loading branch information
JohnTitor authored Dec 12, 2019
2 parents 0f286e8 + 7f87dd1 commit 59eed49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
15 changes: 5 additions & 10 deletions src/libcore/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,7 @@ impl char {
pub fn is_alphabetic(self) -> bool {
match self {
'a'..='z' | 'A'..='Z' => true,
c if c > '\x7f' => derived_property::Alphabetic(c),
_ => false,
c => c > '\x7f' && derived_property::Alphabetic(c),
}
}

Expand Down Expand Up @@ -585,8 +584,7 @@ impl char {
pub fn is_lowercase(self) -> bool {
match self {
'a'..='z' => true,
c if c > '\x7f' => derived_property::Lowercase(c),
_ => false,
c => c > '\x7f' && derived_property::Lowercase(c),
}
}

Expand Down Expand Up @@ -617,8 +615,7 @@ impl char {
pub fn is_uppercase(self) -> bool {
match self {
'A'..='Z' => true,
c if c > '\x7f' => derived_property::Uppercase(c),
_ => false,
c => c > '\x7f' && derived_property::Uppercase(c),
}
}

Expand Down Expand Up @@ -646,8 +643,7 @@ impl char {
pub fn is_whitespace(self) -> bool {
match self {
' ' | '\x09'..='\x0d' => true,
c if c > '\x7f' => property::White_Space(c),
_ => false,
c => c > '\x7f' && property::White_Space(c),
}
}

Expand Down Expand Up @@ -744,8 +740,7 @@ impl char {
pub fn is_numeric(self) -> bool {
match self {
'0'..='9' => true,
c if c > '\x7f' => general_category::N(c),
_ => false,
c => c > '\x7f' && general_category::N(c),
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/libcore/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,7 @@ unsafe impl<'a> Searcher<'a> for CharSearcher<'a> {
fn next_match(&mut self) -> Option<(usize, usize)> {
loop {
// get the haystack after the last character found
let bytes = if let Some(slice) = self.haystack.as_bytes()
.get(self.finger..self.finger_back) {
slice
} else {
return None;
};
let bytes = self.haystack.as_bytes().get(self.finger..self.finger_back)?;
// the last byte of the utf8 encoded needle
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) };
if let Some(index) = memchr::memchr(last_byte, bytes) {
Expand Down

0 comments on commit 59eed49

Please sign in to comment.