mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Pass a Vec to ApplicableDeclarationsCacheEntry::new.
As it copies the slice anyway, it is better to give the caller the opportunity to pass in an existing Vec.
This commit is contained in:
parent
f8785beb24
commit
b14a94a30f
1 changed files with 4 additions and 8 deletions
|
@ -55,13 +55,9 @@ pub struct ApplicableDeclarationsCacheEntry {
|
|||
}
|
||||
|
||||
impl ApplicableDeclarationsCacheEntry {
|
||||
fn new(slice: &[DeclarationBlock]) -> ApplicableDeclarationsCacheEntry {
|
||||
let mut entry_declarations = Vec::new();
|
||||
for declarations in slice.iter() {
|
||||
entry_declarations.push(declarations.clone());
|
||||
}
|
||||
fn new(declarations: Vec<DeclarationBlock>) -> ApplicableDeclarationsCacheEntry {
|
||||
ApplicableDeclarationsCacheEntry {
|
||||
declarations: entry_declarations,
|
||||
declarations: declarations,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +134,7 @@ impl ApplicableDeclarationsCache {
|
|||
}
|
||||
}
|
||||
|
||||
fn insert(&mut self, declarations: &[DeclarationBlock], style: Arc<ComputedValues>) {
|
||||
fn insert(&mut self, declarations: Vec<DeclarationBlock>, style: Arc<ComputedValues>) {
|
||||
self.cache.insert(ApplicableDeclarationsCacheEntry::new(declarations), style)
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +434,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
|
|||
|
||||
// Cache the resolved style if it was cacheable.
|
||||
if cacheable {
|
||||
applicable_declarations_cache.insert(applicable_declarations, this_style.clone());
|
||||
applicable_declarations_cache.insert(applicable_declarations.to_vec(), this_style.clone());
|
||||
}
|
||||
|
||||
// Calculate style difference and write.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue