Skip to content

Commit 3feaa5c

Browse files
Prettify capacity contant definition a little.
1 parent 33517ab commit 3feaa5c

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/inline_string.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use std::convert::{Infallible, TryFrom};
3939
use std::fmt::{self, Display};
4040
use std::hash;
4141
use std::io::Write;
42+
use std::mem;
4243
use std::ops::{self, RangeBounds};
4344
use std::ptr;
4445
use std::str;
@@ -49,14 +50,8 @@ use std::str;
4950
/// Sometime in the future, when Rust's generics support specializing with
5051
/// compile-time static integers, this number should become configurable.
5152
pub const INLINE_STRING_CAPACITY: usize = {
52-
#[cfg(target_pointer_width = "64")]
53-
{
54-
30
55-
}
56-
#[cfg(target_pointer_width = "32")]
57-
{
58-
14
59-
}
53+
use mem::size_of;
54+
size_of::<String>() + size_of::<usize>() - 2
6055
};
6156

6257
/// A short UTF-8 string that uses inline storage and does no heap allocation.

0 commit comments

Comments
 (0)