mirror of
https://github.com/Dangoware/dmp-core.git
synced 2025-04-19 17:42:56 -05:00
Added benchmark for testing
This commit is contained in:
parent
eeceb27800
commit
421ab0c757
2 changed files with 5 additions and 4 deletions
|
@ -85,6 +85,6 @@ impl MusicController {
|
||||||
sort_by: Vec<Tag>,
|
sort_by: Vec<Tag>,
|
||||||
) -> Option<Vec<&Song>> {
|
) -> Option<Vec<&Song>> {
|
||||||
self.library
|
self.library
|
||||||
.query(query_string, &target_tags, &sort_by)
|
.query_tracks(query_string, &target_tags, &sort_by)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -664,7 +664,7 @@ impl MusicLibrary {
|
||||||
///
|
///
|
||||||
/// Example:
|
/// Example:
|
||||||
/// ```
|
/// ```
|
||||||
/// query(
|
/// query_tracks(
|
||||||
/// &String::from("query"),
|
/// &String::from("query"),
|
||||||
/// &vec![
|
/// &vec![
|
||||||
/// Tag::Title
|
/// Tag::Title
|
||||||
|
@ -680,7 +680,7 @@ impl MusicLibrary {
|
||||||
/// This would find all titles containing the sequence
|
/// This would find all titles containing the sequence
|
||||||
/// "query", and would return the results sorted first
|
/// "query", and would return the results sorted first
|
||||||
/// by path, then album, disk number, and finally track number.
|
/// by path, then album, disk number, and finally track number.
|
||||||
pub fn query(
|
pub fn query_tracks(
|
||||||
&self,
|
&self,
|
||||||
query_string: &String, // The query itself
|
query_string: &String, // The query itself
|
||||||
target_tags: &Vec<Tag>, // The tags to search
|
target_tags: &Vec<Tag>, // The tags to search
|
||||||
|
@ -773,7 +773,7 @@ impl MusicLibrary {
|
||||||
None => continue
|
None => continue
|
||||||
};
|
};
|
||||||
|
|
||||||
match albums.binary_search_by_key(&normalize(&title), |album| normalize(&album.title.to_owned())) {
|
match albums.binary_search_by_key(&title, |album| album.title) {
|
||||||
Ok(pos) => {
|
Ok(pos) => {
|
||||||
albums[pos].tracks.push(result);
|
albums[pos].tracks.push(result);
|
||||||
},
|
},
|
||||||
|
@ -791,4 +791,5 @@ impl MusicLibrary {
|
||||||
|
|
||||||
Ok(albums)
|
Ok(albums)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue