diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-03 15:58:13 -0500 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-03 15:58:13 -0500 |
commit | c87aa399ed082cd751b8947037a5ab16af604d7e (patch) | |
tree | eba582918b78fcf25c84b5484d471aeb4056e571 /components/net | |
parent | b389ecda67d834de1893c6e7a118c0f0fd713b8c (diff) | |
parent | ef341128e21698ba1c5b0b792932fc1660428e54 (diff) | |
download | servo-c87aa399ed082cd751b8947037a5ab16af604d7e.tar.gz servo-c87aa399ed082cd751b8947037a5ab16af604d7e.zip |
Auto merge of #11576 - rwakulszowa:net-filemanager-idmap-drop-refcell, r=nox
Dropped references to RefCell.
Removed RefCell references from net/filemanager_thread.rs
---
<!-- 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
- [X] These changes fix #11466
<!-- Either: -->
- [X] These changes do not require tests because @jdm said so :)
<!-- 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/11576)
<!-- Reviewable:end -->
Diffstat (limited to 'components/net')
-rw-r--r-- | components/net/filemanager_thread.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/components/net/filemanager_thread.rs b/components/net/filemanager_thread.rs index 4fb4eea3fd9..fc65446a587 100644 --- a/components/net/filemanager_thread.rs +++ b/components/net/filemanager_thread.rs @@ -6,7 +6,6 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use mime_guess::guess_mime_type_opt; use net_traits::filemanager_thread::{FileManagerThreadMsg, FileManagerResult}; use net_traits::filemanager_thread::{SelectedFile, FileManagerThreadError}; -use std::cell::RefCell; use std::collections::HashMap; use std::fs::File; use std::io::Read; @@ -16,7 +15,7 @@ use uuid::Uuid; pub struct FileManager { receiver: IpcReceiver<FileManagerThreadMsg>, - idmap: RefCell<HashMap<Uuid, PathBuf>>, + idmap: HashMap<Uuid, PathBuf>, } pub trait FileManagerThreadFactory { @@ -41,7 +40,7 @@ impl FileManager { fn new(recv: IpcReceiver<FileManagerThreadMsg>) -> FileManager { FileManager { receiver: recv, - idmap: RefCell::new(HashMap::new()), + idmap: HashMap::new(), } } @@ -96,7 +95,7 @@ impl FileManager { match File::open(file_path) { Ok(handler) => { let id = Uuid::new_v4(); - self.idmap.borrow_mut().insert(id, file_path.to_path_buf()); + self.idmap.insert(id, file_path.to_path_buf()); // Unix Epoch: https://doc.servo.org/std/time/constant.UNIX_EPOCH.html let epoch = handler.metadata().and_then(|metadata| metadata.modified()).map_err(|_| ()) @@ -132,7 +131,7 @@ impl FileManager { } fn read_file(&mut self, sender: IpcSender<FileManagerResult<Vec<u8>>>, id: Uuid) { - match self.idmap.borrow().get(&id).and_then(|filepath| { + match self.idmap.get(&id).and_then(|filepath| { let mut buffer = vec![]; match File::open(&filepath) { Ok(mut handler) => { @@ -154,6 +153,6 @@ impl FileManager { } fn delete_fileid(&mut self, id: Uuid) { - self.idmap.borrow_mut().remove(&id); + self.idmap.remove(&id); } } |