summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-02-18 17:33:13 +0100
committerLaurenz <laurmaedje@gmail.com>2022-02-18 17:33:13 +0100
commit61d1e1a6831113143c5d1e9f8ccf2a86f90f359a (patch)
tree27c85e1ee876941bba558bb187885ccc4a76f87d /src/layout
parente01970b20a058ab1b4ebea916f229c9b706c84e4 (diff)
Remove layout-cache feature
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/incremental.rs15
-rw-r--r--src/layout/mod.rs30
2 files changed, 1 insertions, 44 deletions
diff --git a/src/layout/incremental.rs b/src/layout/incremental.rs
index 2112fef1..b68ddcdc 100644
--- a/src/layout/incremental.rs
+++ b/src/layout/incremental.rs
@@ -11,8 +11,6 @@ use crate::geom::Scalar;
const TEMP_LEN: usize = 4;
/// Caches layouting artifacts.
-///
-/// _This is only available when the `layout-cache` feature is enabled._
#[derive(Default, Clone)]
pub struct LayoutCache {
/// Maps from node hashes to the resulting frames and regions in which the
@@ -150,14 +148,6 @@ impl LayoutCache {
entries.retain(|f| f.hits() as f64 / f.age() as f64 > threshold);
}
}
- #[cfg(feature = "rand")]
- EvictionPolicy::Random => {
- // Fraction of items that should be kept.
- let threshold = self.max_size as f64 / len as f64;
- for entries in self.frames.values_mut() {
- entries.retain(|_| rand::random::<f64>() > threshold);
- }
- }
EvictionPolicy::Patterns => {
let kept = self.entries().filter(|f| f.properties().must_keep()).count();
@@ -188,8 +178,6 @@ impl LayoutCache {
}
/// Cached frames from past layouting.
-///
-/// _This is only available when the `layout-cache` feature is enabled._
#[derive(Debug, Clone)]
pub struct FramesEntry {
/// The cached frames for a node.
@@ -340,9 +328,6 @@ pub enum EvictionPolicy {
LeastRecentlyUsed,
/// Evict the least frequently used item.
LeastFrequentlyUsed,
- /// Evict randomly.
- #[cfg(feature = "rand")]
- Random,
/// Use the pattern verdicts.
Patterns,
/// Do not evict.
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 0d1836fd..afb2621b 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -1,12 +1,10 @@
//! Layouting infrastructure.
mod constraints;
-#[cfg(feature = "layout-cache")]
mod incremental;
mod regions;
pub use constraints::*;
-#[cfg(feature = "layout-cache")]
pub use incremental::*;
pub use regions::*;
@@ -141,10 +139,6 @@ impl Layout for LayoutNode {
) -> TypResult<Vec<Constrained<Arc<Frame>>>> {
let styles = styles.barred(self.id());
- #[cfg(not(feature = "layout-cache"))]
- return self.0.layout(ctx, regions, styles);
-
- #[cfg(feature = "layout-cache")]
let hash = {
let mut state = fxhash::FxHasher64::default();
self.hash(&mut state);
@@ -154,7 +148,6 @@ impl Layout for LayoutNode {
// This is not written with `unwrap_or_else`, because then the
// #[track_caller] annotation doesn't work.
- #[cfg(feature = "layout-cache")]
if let Some(frames) = vm.layout_cache.get(hash, regions) {
Ok(frames)
} else {
@@ -199,18 +192,12 @@ impl Debug for LayoutNode {
impl PartialEq for LayoutNode {
fn eq(&self, other: &Self) -> bool {
- // We cast to thin pointers for comparison because we don't want to
- // compare vtables (which can be different across codegen units).
- std::ptr::eq(
- Arc::as_ptr(&self.0) as *const (),
- Arc::as_ptr(&other.0) as *const (),
- )
+ self.0.eq(&other.0)
}
}
trait Bounds: Layout + Debug + Sync + Send + 'static {
fn as_any(&self) -> &dyn Any;
- fn hash64(&self) -> u64;
}
impl<T> Bounds for T
@@ -220,21 +207,6 @@ where
fn as_any(&self) -> &dyn Any {
self
}
-
- fn hash64(&self) -> u64 {
- // Also hash the TypeId since nodes with different types but
- // equal data should be different.
- let mut state = fxhash::FxHasher64::default();
- self.type_id().hash(&mut state);
- self.hash(&mut state);
- state.finish()
- }
-}
-
-impl Hash for dyn Bounds {
- fn hash<H: Hasher>(&self, state: &mut H) {
- state.write_u64(self.hash64());
- }
}
/// A layout node that produces an empty frame.