Skip to content

Commit 3d58543

Browse files
committed
Avoid unnecessary calculation
1 parent 683bdc7 commit 3d58543

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/liballoc/str.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2113,9 +2113,9 @@ impl str {
21132113
(buf.as_mut_ptr() as *mut u8).add(buf.len()),
21142114
rem_len,
21152115
);
2116-
// `buf.len() + rem_len` equals to `buf.capacity()` (`self.len() * n`).
2117-
let buf_len = buf.len();
2118-
buf.set_len(buf_len + rem_len);
2116+
// `buf.len() + rem_len` equals to `buf.capacity()` (`= self.len() * n`).
2117+
let buf_cap = buf.capacity();
2118+
buf.set_len(buf_cap);
21192119
}
21202120
}
21212121

0 commit comments

Comments
 (0)