Skip to content

Commit

Permalink
Avoid unnecessary calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkuu committed Mar 4, 2018
1 parent 683bdc7 commit 3d58543
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/liballoc/str.rs
Expand Up @@ -2113,9 +2113,9 @@ impl str {
(buf.as_mut_ptr() as *mut u8).add(buf.len()),
rem_len,
);
// `buf.len() + rem_len` equals to `buf.capacity()` (`self.len() * n`).
let buf_len = buf.len();
buf.set_len(buf_len + rem_len);
// `buf.len() + rem_len` equals to `buf.capacity()` (`= self.len() * n`).
let buf_cap = buf.capacity();
buf.set_len(buf_cap);
}
}

Expand Down

0 comments on commit 3d58543

Please sign in to comment.