file_model: Remove next() and previous() functions
These functions required iterating to find the index of a file and then adding one to it. We can be smarter, using an index we already have and adding or subtracting where appropriate.
This commit is contained in:
parent
10cdb2c519
commit
e13ecb4df4
2 changed files with 6 additions and 23 deletions
|
|
@ -115,24 +115,6 @@ impl LpFileModel {
|
|||
model
|
||||
}
|
||||
|
||||
pub fn previous(&self, current: &gio::File) -> Option<gio::File> {
|
||||
let imp = self.imp();
|
||||
|
||||
let vec = imp.inner.borrow();
|
||||
let index = vec.iter().position(|f| f.equal(current))?;
|
||||
|
||||
vec.get(index.checked_sub(1)?).cloned()
|
||||
}
|
||||
|
||||
pub fn next(&self, current: &gio::File) -> Option<gio::File> {
|
||||
let imp = self.imp();
|
||||
|
||||
let vec = imp.inner.borrow();
|
||||
let index = vec.iter().position(|f| f.equal(current))?;
|
||||
|
||||
vec.get(index + 1).cloned()
|
||||
}
|
||||
|
||||
pub fn directory(&self) -> Option<gio::File> {
|
||||
self.imp().directory.get().cloned()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue