mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23: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::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::RwLock;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
|
||||||
pub enum PrefValue {
|
pub enum PrefValue {
|
||||||
|
@ -184,7 +184,7 @@ impl<P, V> Accessor<P, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Preferences<'m, P> {
|
pub struct Preferences<'m, P> {
|
||||||
user_prefs: Arc<RwLock<P>>,
|
user_prefs: RwLock<P>,
|
||||||
default_prefs: P,
|
default_prefs: P,
|
||||||
accessors: &'m HashMap<String, Accessor<P, PrefValue>>,
|
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`.
|
/// can always be restored using `reset` or `reset_all`.
|
||||||
pub fn new(default_prefs: P, accessors: &'m HashMap<String, Accessor<P, PrefValue>>) -> Self {
|
pub fn new(default_prefs: P, accessors: &'m HashMap<String, Accessor<P, PrefValue>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
user_prefs: Arc::new(RwLock::new(default_prefs.clone())),
|
user_prefs: RwLock::new(default_prefs.clone()),
|
||||||
default_prefs,
|
default_prefs,
|
||||||
accessors,
|
accessors,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Access to the data structure holding the preference values.
|
/// Access to the data structure holding the preference values.
|
||||||
pub fn values(&self) -> Arc<RwLock<P>> {
|
pub fn values(&self) -> &RwLock<P> {
|
||||||
Arc::clone(&self.user_prefs)
|
&self.user_prefs
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve a preference using its key
|
/// Retrieve a preference using its key
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue