Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRefactor `util::prefs` operations to be methods on static struct. #12178
Conversation
highfive
commented
Jul 2, 2016
|
Heads up! This PR modifies the following files:
|
|
I was never a fan of the assortment of functions in |
|
Tidy:
|
|
|
| @@ -14,9 +14,9 @@ use std::path::PathBuf; | |||
| use std::sync::{Arc, Mutex}; | |||
|
|
|||
| lazy_static! { | |||
| static ref PREFS: Arc<Mutex<HashMap<String, Pref>>> = { | |||
| pub static ref PREFS: Preferences = { | |||
| let prefs = read_prefs().unwrap_or(HashMap::new()); | |||
This comment has been minimized.
This comment has been minimized.
emilio
Jul 2, 2016
Member
now you're at it, could you change this unwrap_or(HashMap::new()) for unwrap_or_else(HashMap::new)?
It's a nit though, so feel free to not do it :)
This comment has been minimized.
This comment has been minimized.
| let prefs = read_prefs().unwrap_or(HashMap::new()); | ||
| Arc::new(Mutex::new(prefs)) | ||
| Preferences(Arc::new(Mutex::new(prefs))) |
This comment has been minimized.
This comment has been minimized.
emilio
Jul 2, 2016
Member
Actually, I'm wondering if we could use a RWLock instead of a Mutex, this should avoid locking the world when reading preferences, which is the common case.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
maybe @bors-servo: delegate+ |
|
|
|
@bors-servo r=emilio |
|
|
Refactor `util::prefs` operations to be methods on static struct. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12178) <!-- Reviewable:end -->
|
|
frewsxcv commentedJul 2, 2016
•
edited by larsbergstrom
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is