Hoist the LRU cache into its own crate to share it with selectors.

This commit is contained in:
Bobby Holley 2017-09-20 18:38:20 -07:00
parent 5afb1b7dd2
commit 8b6c5988b5
9 changed files with 30 additions and 3 deletions

9
Cargo.lock generated
View file

@ -1704,6 +1704,13 @@ name = "log"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lru_cache"
version = "0.0.1"
dependencies = [
"arrayvec 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lzw"
version = "0.10.0"
@ -2712,6 +2719,7 @@ dependencies = [
"cssparser 0.21.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lru_cache 0.0.1",
"malloc_size_of 0.0.1",
"malloc_size_of_derive 0.0.1",
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3128,6 +3136,7 @@ dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lru_cache 0.0.1",
"malloc_size_of 0.0.1",
"malloc_size_of_derive 0.0.1",
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -0,0 +1,13 @@
[package]
name = "lru_cache"
version = "0.0.1"
authors = ["The Servo Project Developers"]
license = "MPL-2.0"
publish = false # We should publish this at some point
[lib]
name = "lru_cache"
path = "lib.rs"
[dependencies]
arrayvec = "0.3.20"

View file

@ -4,6 +4,8 @@
//! A simple LRU cache.
extern crate arrayvec;
use arrayvec::{Array, ArrayVec};
/// A LRU cache using a statically-sized array for storage.

View file

@ -30,6 +30,7 @@ log = "0.3"
fnv = "1.0"
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
lru_cache = { path = "../lru_cache" }
phf = "0.7.18"
precomputed-hash = "0.1"
servo_arc = { path = "../servo_arc" }

View file

@ -10,6 +10,7 @@
#[macro_use] extern crate log;
#[macro_use] extern crate matches;
extern crate fnv;
extern crate lru_cache;
extern crate malloc_size_of;
#[macro_use] extern crate malloc_size_of_derive;
extern crate phf;

View file

@ -48,6 +48,7 @@ itertools = "0.5"
itoa = "0.3"
html5ever = {version = "0.19", optional = true}
lazy_static = "0.2"
lru_cache = { path = "../lru_cache" }
log = "0.3"
malloc_size_of = { path = "../malloc_size_of", optional=true }
malloc_size_of_derive = { path = "../malloc_size_of_derive", optional=true }

View file

@ -8,13 +8,13 @@
#[cfg(feature = "servo")] use animation::PropertyAnimation;
use app_units::Au;
use bloom::StyleBloom;
use cache::{Entry, LRUCache};
use data::{EagerPseudoStyles, ElementData};
use dom::{OpaqueNode, TNode, TElement, SendElement};
use euclid::ScaleFactor;
use euclid::Size2D;
use fnv::FnvHashMap;
use font_metrics::FontMetricsProvider;
use lru_cache::{Entry, LRUCache};
#[cfg(feature = "gecko")] use gecko_bindings::structs;
use parallel::{STACK_SAFETY_MARGIN_KB, STYLE_THREAD_STACK_SIZE_KB};
#[cfg(feature = "servo")] use parking_lot::RwLock;

View file

@ -59,6 +59,7 @@ extern crate itoa;
extern crate lazy_static;
#[macro_use]
extern crate log;
extern crate lru_cache;
#[cfg(feature = "gecko")] #[macro_use] extern crate malloc_size_of;
#[cfg(feature = "gecko")] #[macro_use] extern crate malloc_size_of_derive;
#[allow(unused_extern_crates)]
@ -102,7 +103,6 @@ pub mod applicable_declarations;
#[cfg(feature = "servo")] pub mod attr;
pub mod bezier;
pub mod bloom;
pub mod cache;
pub mod context;
pub mod counter_style;
pub mod custom_properties;

View file

@ -68,9 +68,9 @@ use Atom;
use applicable_declarations::ApplicableDeclarationBlock;
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use bloom::StyleBloom;
use cache::{LRUCache, Entry};
use context::{SelectorFlagsMap, SharedStyleContext, StyleContext};
use dom::{TElement, SendElement};
use lru_cache::{LRUCache, Entry};
use matching::MatchMethods;
use owning_ref::OwningHandle;
use properties::ComputedValues;