Skip to content

Commit e1eff20

Browse files
authored
Add inline attribute to String::from_str_in (#290)
Saw that `String::from_str_in` pop up in my own application benchmark profiling. It seems like a good candidate for inlining as `String::with_capacity_in` is inlined and `String::from_str_in` isn't doing much work other than that. Running the bumpalo benchmarks, the from_str_in did not see any changes, though my own benchmarks show a consistent 5-10% improvement in latency.
1 parent 44a07b9 commit e1eff20

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/collections/string.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ impl<'bump> String<'bump> {
679679
/// let s = String::from_str_in("hello", &b);
680680
/// assert_eq!(s, "hello");
681681
/// ```
682+
#[inline]
682683
pub fn from_str_in(s: &str, bump: &'bump Bump) -> String<'bump> {
683684
let len = s.len();
684685
let mut t = String::with_capacity_in(len, bump);

0 commit comments

Comments
 (0)