mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Even more inline aggression
This commit is contained in:
parent
c53719eb95
commit
7b8e1e1d53
1 changed files with 8 additions and 0 deletions
|
@ -269,12 +269,14 @@ const NAKED_RECURSION_PTR: CacheCriteria = CacheCriteria {
|
||||||
};
|
};
|
||||||
|
|
||||||
impl CacheCriteria {
|
impl CacheCriteria {
|
||||||
|
#[inline(always)]
|
||||||
fn is_cacheable(&self) -> bool {
|
fn is_cacheable(&self) -> bool {
|
||||||
// Can't cache if there a naked recursion pointer that isn't covered by a recursive layout.
|
// Can't cache if there a naked recursion pointer that isn't covered by a recursive layout.
|
||||||
!self.has_naked_recursion_pointer
|
!self.has_naked_recursion_pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Makes `self` cacheable iff self and other are cacheable.
|
/// Makes `self` cacheable iff self and other are cacheable.
|
||||||
|
#[inline(always)]
|
||||||
fn and(&mut self, other: Self) {
|
fn and(&mut self, other: Self) {
|
||||||
self.has_naked_recursion_pointer =
|
self.has_naked_recursion_pointer =
|
||||||
self.has_naked_recursion_pointer || other.has_naked_recursion_pointer;
|
self.has_naked_recursion_pointer || other.has_naked_recursion_pointer;
|
||||||
|
@ -284,11 +286,13 @@ impl CacheCriteria {
|
||||||
.or(other.has_recursive_structure);
|
.or(other.has_recursive_structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn pass_through_recursive_union(&mut self, recursion_var: Variable) {
|
fn pass_through_recursive_union(&mut self, recursion_var: Variable) {
|
||||||
self.has_naked_recursion_pointer = false;
|
self.has_naked_recursion_pointer = false;
|
||||||
self.has_recursive_structure = Some(recursion_var);
|
self.has_recursive_structure = Some(recursion_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn cache_metadata(&self) -> CacheMeta {
|
fn cache_metadata(&self) -> CacheMeta {
|
||||||
CacheMeta {
|
CacheMeta {
|
||||||
has_recursive_structure: self.has_recursive_structure,
|
has_recursive_structure: self.has_recursive_structure,
|
||||||
|
@ -300,22 +304,26 @@ impl CacheCriteria {
|
||||||
pub(crate) struct Cacheable<T>(T, CacheCriteria);
|
pub(crate) struct Cacheable<T>(T, CacheCriteria);
|
||||||
|
|
||||||
impl<T> Cacheable<T> {
|
impl<T> Cacheable<T> {
|
||||||
|
#[inline(always)]
|
||||||
fn map<U>(self, f: impl FnOnce(T) -> U) -> Cacheable<U> {
|
fn map<U>(self, f: impl FnOnce(T) -> U) -> Cacheable<U> {
|
||||||
Cacheable(f(self.0), self.1)
|
Cacheable(f(self.0), self.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn decompose(self, and_with: &mut CacheCriteria) -> T {
|
fn decompose(self, and_with: &mut CacheCriteria) -> T {
|
||||||
let Self(value, criteria) = self;
|
let Self(value, criteria) = self;
|
||||||
and_with.and(criteria);
|
and_with.and(criteria);
|
||||||
value
|
value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn value(self) -> T {
|
pub fn value(self) -> T {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, E> Cacheable<Result<T, E>> {
|
impl<T, E> Cacheable<Result<T, E>> {
|
||||||
|
#[inline(always)]
|
||||||
fn then<U>(self, f: impl FnOnce(T) -> U) -> Cacheable<Result<U, E>> {
|
fn then<U>(self, f: impl FnOnce(T) -> U) -> Cacheable<Result<U, E>> {
|
||||||
let Cacheable(result, criteria) = self;
|
let Cacheable(result, criteria) = self;
|
||||||
match result {
|
match result {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue