Change StaticVec to 3 inline elements.
This commit is contained in:
parent
43de522568
commit
84be799403
@ -46,6 +46,7 @@ Enhancements
|
|||||||
* Added `ASTNode::position`.
|
* Added `ASTNode::position`.
|
||||||
* `ReturnType` is removed in favor of option flags for `Stmt::Return`.
|
* `ReturnType` is removed in favor of option flags for `Stmt::Return`.
|
||||||
* `Stmt::Break` and `Stmt::Continue` are merged into `Stmt::BreakLoop` via an option flag.
|
* `Stmt::Break` and `Stmt::Continue` are merged into `Stmt::BreakLoop` via an option flag.
|
||||||
|
* `StaticVec` is changed to keep three items inline instead of four.
|
||||||
|
|
||||||
|
|
||||||
Version 1.0.4
|
Version 1.0.4
|
||||||
|
@ -180,7 +180,7 @@ impl Imports {
|
|||||||
impl IntoIterator for Imports {
|
impl IntoIterator for Imports {
|
||||||
type Item = (Identifier, Shared<Module>);
|
type Item = (Identifier, Shared<Module>);
|
||||||
type IntoIter =
|
type IntoIter =
|
||||||
Zip<Rev<smallvec::IntoIter<[Identifier; 4]>>, Rev<smallvec::IntoIter<[Shared<Module>; 4]>>>;
|
Zip<Rev<smallvec::IntoIter<[Identifier; 3]>>, Rev<smallvec::IntoIter<[Shared<Module>; 3]>>>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
46
src/lib.rs
46
src/lib.rs
@ -246,8 +246,8 @@ pub use engine::Limits;
|
|||||||
#[deprecated = "this type is volatile and may change"]
|
#[deprecated = "this type is volatile and may change"]
|
||||||
pub use module::NamespaceRef;
|
pub use module::NamespaceRef;
|
||||||
|
|
||||||
/// Alias to [`smallvec::SmallVec<[T; 4]>`](https://crates.io/crates/smallvec), which is a
|
/// Alias to [`smallvec::SmallVec<[T; 3]>`](https://crates.io/crates/smallvec), which is a
|
||||||
/// specialized [`Vec`] backed by a small, inline, fixed-size array when there are ≤ 4 items stored.
|
/// specialized [`Vec`] backed by a small, inline, fixed-size array when there are ≤ 3 items stored.
|
||||||
///
|
///
|
||||||
/// # History
|
/// # History
|
||||||
///
|
///
|
||||||
@ -258,30 +258,30 @@ pub use module::NamespaceRef;
|
|||||||
/// and orangutans and breakfast cereals and fruit bats and large chu...
|
/// and orangutans and breakfast cereals and fruit bats and large chu...
|
||||||
///
|
///
|
||||||
/// And the Lord spake, saying, "First shalt thou depend on the [`smallvec`](https://crates.io/crates/smallvec) crate.
|
/// And the Lord spake, saying, "First shalt thou depend on the [`smallvec`](https://crates.io/crates/smallvec) crate.
|
||||||
/// Then, shalt thou keep four inline. No more. No less. Four shalt be the number thou shalt keep inline,
|
/// Then, shalt thou keep three inline. No more. No less. Three shalt be the number thou shalt keep inline,
|
||||||
/// and the number to keep inline shalt be four. Five shalt thou not keep inline, nor either keep inline
|
/// and the number to keep inline shalt be three. Four shalt thou not keep inline, nor either keep inline
|
||||||
/// thou two or three, excepting that thou then proceed to four. Six is right out. Once the number four,
|
/// thou two, excepting that thou then proceed to three. Five is right out. Once the number three,
|
||||||
/// being the forth number, be reached, then, lobbest thou thy `SmallVec` towards thy heap, who,
|
/// being the third number, be reached, then, lobbest thou thy `SmallVec` towards thy heap, who,
|
||||||
/// being slow and cache-naughty in My sight, shall snuff it."
|
/// being slow and cache-naughty in My sight, shall snuff it."
|
||||||
///
|
///
|
||||||
/// # Explanation on the Number Four
|
/// # Explanation on the Number Three
|
||||||
///
|
///
|
||||||
/// `StaticVec` is used frequently to keep small lists of items in inline (non-heap) storage in
|
/// `StaticVec` is used frequently to keep small lists of items in inline (non-heap) storage in
|
||||||
/// order to improve cache friendliness and reduce indirections.
|
/// order to improve cache friendliness and reduce indirections.
|
||||||
///
|
///
|
||||||
/// The number 4, other than being the holy number, is carefully chosen for a balance between
|
/// The number 3, other than being the holy number, is carefully chosen for a balance between
|
||||||
/// storage space and reduce allocations. That is because most function calls (and most functions,
|
/// storage space and reduce allocations. That is because most function calls (and most functions,
|
||||||
/// in that matter) contain fewer than 5 arguments, the exception being closures that capture a
|
/// in that matter) contain fewer than 4 arguments, the exception being closures that capture a
|
||||||
/// large number of external variables.
|
/// large number of external variables.
|
||||||
///
|
///
|
||||||
/// In addition, most script blocks either contain many statements, or just a few lines;
|
/// In addition, most script blocks either contain many statements, or just a few lines;
|
||||||
/// most scripts load fewer than 5 external modules; most module paths contain fewer than 5 levels
|
/// most scripts load fewer than 4 external modules; most module paths contain fewer than 4 levels
|
||||||
/// (e.g. `std::collections::map::HashMap` is 4 levels, and that's already quite long).
|
/// (e.g. `std::collections::map::HashMap` is 4 levels).
|
||||||
#[cfg(not(feature = "internals"))]
|
#[cfg(not(feature = "internals"))]
|
||||||
type StaticVec<T> = smallvec::SmallVec<[T; 4]>;
|
type StaticVec<T> = smallvec::SmallVec<[T; 3]>;
|
||||||
|
|
||||||
/// _(internals)_ Alias to [`smallvec`](https://crates.io/crates/smallvec), which is a specialized
|
/// _(internals)_ Alias to [`smallvec`](https://crates.io/crates/smallvec), which is a specialized
|
||||||
/// [`Vec`] backed by a small, inline, fixed-size array when there are ≤ 4 items stored.
|
/// [`Vec`] backed by a small, inline, fixed-size array when there are ≤ 3 items stored.
|
||||||
/// Exported under the `internals` feature only.
|
/// Exported under the `internals` feature only.
|
||||||
///
|
///
|
||||||
/// # History
|
/// # History
|
||||||
@ -293,27 +293,27 @@ type StaticVec<T> = smallvec::SmallVec<[T; 4]>;
|
|||||||
/// and orangutans and breakfast cereals and fruit bats and large chu...
|
/// and orangutans and breakfast cereals and fruit bats and large chu...
|
||||||
///
|
///
|
||||||
/// And the Lord spake, saying, "First shalt thou depend on the [`smallvec`](https://crates.io/crates/smallvec) crate.
|
/// And the Lord spake, saying, "First shalt thou depend on the [`smallvec`](https://crates.io/crates/smallvec) crate.
|
||||||
/// Then, shalt thou keep four inline. No more. No less. Four shalt be the number thou shalt keep inline,
|
/// Then, shalt thou keep three inline. No more. No less. Three shalt be the number thou shalt keep inline,
|
||||||
/// and the number to keep inline shalt be four. Five shalt thou not keep inline, nor either keep inline
|
/// and the number to keep inline shalt be three. Four shalt thou not keep inline, nor either keep inline
|
||||||
/// thou two or three, excepting that thou then proceed to four. Six is right out. Once the number four,
|
/// thou two, excepting that thou then proceed to three. Five is right out. Once the number three,
|
||||||
/// being the forth number, be reached, then, lobbest thou thy `SmallVec` towards thy heap, who,
|
/// being the third number, be reached, then, lobbest thou thy `SmallVec` towards thy heap, who,
|
||||||
/// being slow and cache-naughty in My sight, shall snuff it."
|
/// being slow and cache-naughty in My sight, shall snuff it."
|
||||||
///
|
///
|
||||||
/// # Explanation on the Number Four
|
/// # Explanation on the Number Three
|
||||||
///
|
///
|
||||||
/// `StaticVec` is used frequently to keep small lists of items in inline (non-heap) storage in
|
/// `StaticVec` is used frequently to keep small lists of items in inline (non-heap) storage in
|
||||||
/// order to improve cache friendliness and reduce indirections.
|
/// order to improve cache friendliness and reduce indirections.
|
||||||
///
|
///
|
||||||
/// The number 4, other than being the holy number, is carefully chosen for a balance between
|
/// The number 3, other than being the holy number, is carefully chosen for a balance between
|
||||||
/// storage space and reduce allocations. That is because most function calls (and most functions,
|
/// storage space and reduce allocations. That is because most function calls (and most functions,
|
||||||
/// in that matter) contain fewer than 5 arguments, the exception being closures that capture a
|
/// in that matter) contain fewer than 4 arguments, the exception being closures that capture a
|
||||||
/// large number of external variables.
|
/// large number of external variables.
|
||||||
///
|
///
|
||||||
/// In addition, most script blocks either contain many statements, or just a few lines;
|
/// In addition, most script blocks either contain many statements, or just a few lines;
|
||||||
/// most scripts load fewer than 5 external modules; most module paths contain fewer than 5 levels
|
/// most scripts load fewer than 4 external modules; most module paths contain fewer than 4 levels
|
||||||
/// (e.g. `std::collections::map::HashMap` is 4 levels, and that's already quite long).
|
/// (e.g. `std::collections::map::HashMap` is 4 levels).
|
||||||
#[cfg(feature = "internals")]
|
#[cfg(feature = "internals")]
|
||||||
pub type StaticVec<T> = smallvec::SmallVec<[T; 4]>;
|
pub type StaticVec<T> = smallvec::SmallVec<[T; 3]>;
|
||||||
|
|
||||||
#[cfg(not(feature = "no_smartstring"))]
|
#[cfg(not(feature = "no_smartstring"))]
|
||||||
pub(crate) type SmartString = smartstring::SmartString<smartstring::Compact>;
|
pub(crate) type SmartString = smartstring::SmartString<smartstring::Compact>;
|
||||||
|
@ -24,9 +24,9 @@ fn check_struct_sizes() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
size_of::<FnPtr>(),
|
size_of::<FnPtr>(),
|
||||||
if cfg!(feature = "no_smartstring") {
|
if cfg!(feature = "no_smartstring") {
|
||||||
80
|
64
|
||||||
} else {
|
} else {
|
||||||
96
|
80
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert_eq!(size_of::<Scope>(), 464);
|
assert_eq!(size_of::<Scope>(), 464);
|
||||||
|
Loading…
Reference in New Issue
Block a user