提交 3d58543d 编写于 作者: S Shotaro Yamada

Avoid unnecessary calculation

上级 683bdc7f
......@@ -2113,9 +2113,9 @@ pub fn repeat(&self, n: usize) -> String {
(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);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册