Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor `util::prefs` operations to be methods on static struct. #12178

Merged
merged 2 commits into from Jul 3, 2016

Conversation

@frewsxcv
Copy link
Member

frewsxcv commented Jul 2, 2016


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Jul 2, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/properties.mako.rs, components/style/properties/longhand/box.mako.rs, components/style/stylesheets.rs
  • @asajeffrey: components/constellation/pipeline.rs, components/webdriver_server/lib.rs, components/constellation/constellation.rs
  • @jgraham: components/webdriver_server/lib.rs
  • @KiChjang: components/script/dom/bindings/guard.rs, components/script/dom/htmlmetaelement.rs, components/script/dom/mouseevent.rs, components/script/dom/window.rs, components/script/dom/document.rs, components/script/script_runtime.rs, components/script/dom/testbinding.rs, components/script/timers.rs, components/net/http_loader.rs, components/script/dom/xmlhttprequest.rs, components/script/dom/bindings/codegen/CodegenRust.py, components/script/dom/htmliframeelement.rs, components/net/resource_thread.rs, components/script/dom/htmlanchorelement.rs, components/script/dom/serviceworkerglobalscope.rs
@frewsxcv
Copy link
Member Author

frewsxcv commented Jul 2, 2016

I was never a fan of the assortment of functions in components/util/pref.rs. I publicized the static datastructure in the module and added some methods around it. I think it's cleaner now, but I don't feel strongly. Just experimenting here.

@cbrewster
Copy link
Member

cbrewster commented Jul 2, 2016

Tidy:

Checking files for tidiness...
./components/compositing/compositor.rs:53: use statement is not in alphabetical order
    expected: util::print_tree::PrintTree
    found: util::opts
./components/servo/lib.rs:85: use statement is not in alphabetical order
    expected: util::resource_files::resources_dir_path
    found: util::opts
@frewsxcv frewsxcv force-pushed the frewsxcv:prefs branch from 66d7eaf to 672c138 Jul 2, 2016
@frewsxcv frewsxcv removed the S-fails-tidy label Jul 2, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Jul 2, 2016

The latest upstream changes (presumably #12136) made this pull request unmergeable. Please resolve the merge conflicts.

@frewsxcv frewsxcv force-pushed the frewsxcv:prefs branch from 672c138 to 22928f5 Jul 2, 2016
@@ -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.

@emilio

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.

let prefs = read_prefs().unwrap_or(HashMap::new());
Arc::new(Mutex::new(prefs))
Preferences(Arc::new(Mutex::new(prefs)))

This comment has been minimized.

@emilio

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.

@frewsxcv

frewsxcv Jul 2, 2016

Author Member

Valid suggestion, though could we make that a separate PR?

This comment has been minimized.

@emilio

emilio Jul 2, 2016

Member

Sure :)

@frewsxcv frewsxcv force-pushed the frewsxcv:prefs branch from eeada7d to 6bc0f58 Jul 2, 2016
@emilio
Copy link
Member

emilio commented Jul 2, 2016

maybe .ok().unwrap_or_else(HashMap::new) is a bit cleaner? Not too much though, so feel free to r=me with or without that.

@bors-servo: delegate+

@bors-servo
Copy link
Contributor

bors-servo commented Jul 2, 2016

✌️ @frewsxcv can now approve this pull request

@frewsxcv frewsxcv force-pushed the frewsxcv:prefs branch from 272dae9 to d9c9d4a Jul 2, 2016
@frewsxcv
Copy link
Member Author

frewsxcv commented Jul 2, 2016

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

bors-servo commented Jul 2, 2016

📌 Commit d9c9d4a has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Jul 3, 2016

Testing commit d9c9d4a with merge b0a8ce5...

bors-servo added a commit that referenced this pull request Jul 3, 2016
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 3, 2016

@bors-servo bors-servo merged commit d9c9d4a into servo:master Jul 3, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@frewsxcv frewsxcv deleted the frewsxcv:prefs branch Jul 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.