Skip to content

Commit

Permalink
Misc cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkuu committed Jan 8, 2019
1 parent f671242 commit 12ae365
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ impl<'a> Formatter<'a> {
self.args[i].as_usize()
}
rt::v1::Count::NextParam => {
self.curarg.next().and_then(|arg| arg.as_usize())
self.curarg.next()?.as_usize()
}
}
}
Expand Down Expand Up @@ -1142,15 +1142,15 @@ impl<'a> Formatter<'a> {
sign = Some('+'); width += 1;
}

let mut prefixed = false;
if self.alternate() {
prefixed = true; width += prefix.chars().count();
let prefixed = self.alternate();
if prefixed {
width += prefix.chars().count();
}

// Writes the sign if it exists, and then the prefix if it was requested
let write_prefix = |f: &mut Formatter| {
if let Some(c) = sign {
f.buf.write_str(c.encode_utf8(&mut [0; 4]))?;
f.buf.write_char(c)?;
}
if prefixed { f.buf.write_str(prefix) }
else { Ok(()) }
Expand Down Expand Up @@ -1312,7 +1312,7 @@ impl<'a> Formatter<'a> {

// remove the sign from the formatted parts
formatted.sign = b"";
width = if width < sign.len() { 0 } else { width - sign.len() };
width = width.saturating_sub(sign.len());
align = rt::v1::Alignment::Right;
self.fill = '0';
self.align = rt::v1::Alignment::Right;
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,7 @@ impl<'a> Pattern<'a> for char {
#[inline]
fn into_searcher(self, haystack: &'a str) -> Self::Searcher {
let mut utf8_encoded = [0; 4];
self.encode_utf8(&mut utf8_encoded);
let utf8_size = self.len_utf8();
let utf8_size = self.encode_utf8(&mut utf8_encoded).len();
CharSearcher {
haystack,
finger: 0,
Expand Down

0 comments on commit 12ae365

Please sign in to comment.