mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Remove an unneeded arc reference count bump on each pref access.
This commit is contained in:
parent
ac09fdf0c7
commit
cb76dbabf4
1 changed files with 5 additions and 5 deletions
|
@ -6,7 +6,7 @@ use serde_json::Value;
|
|||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::sync::RwLock;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
||||
pub enum PrefValue {
|
||||
|
@ -184,7 +184,7 @@ impl<P, V> Accessor<P, V> {
|
|||
}
|
||||
|
||||
pub struct Preferences<'m, P> {
|
||||
user_prefs: Arc<RwLock<P>>,
|
||||
user_prefs: RwLock<P>,
|
||||
default_prefs: P,
|
||||
accessors: &'m HashMap<String, Accessor<P, PrefValue>>,
|
||||
}
|
||||
|
@ -194,15 +194,15 @@ impl<'m, P: Clone> Preferences<'m, P> {
|
|||
/// can always be restored using `reset` or `reset_all`.
|
||||
pub fn new(default_prefs: P, accessors: &'m HashMap<String, Accessor<P, PrefValue>>) -> Self {
|
||||
Self {
|
||||
user_prefs: Arc::new(RwLock::new(default_prefs.clone())),
|
||||
user_prefs: RwLock::new(default_prefs.clone()),
|
||||
default_prefs,
|
||||
accessors,
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the data structure holding the preference values.
|
||||
pub fn values(&self) -> Arc<RwLock<P>> {
|
||||
Arc::clone(&self.user_prefs)
|
||||
pub fn values(&self) -> &RwLock<P> {
|
||||
&self.user_prefs
|
||||
}
|
||||
|
||||
/// Retrieve a preference using its key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue