libsaria: Change the path_list to a vector
For easier lookups. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
8f7a610d6d
commit
592a924881
|
@ -11,12 +11,12 @@
|
|||
#include <fs.h>
|
||||
#include "library.h"
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
static unsigned int next_id = 0;
|
||||
static list<struct libsaria::library::Path> path_list;
|
||||
static vector<struct libsaria::library::Path> path_list;
|
||||
libsaria::Playlist lib_playlist(PL_STATIC | PL_NO_DRAIN | PL_SORTED);
|
||||
|
||||
libsaria::library::Path *push_path(libsaria::library::Path &path)
|
||||
|
@ -69,11 +69,10 @@ static bool check_trackid(libsaria::Track &track, void *data)
|
|||
|
||||
void pop_path(libsaria::library::Path *path)
|
||||
{
|
||||
list<libsaria::library::Path>::iterator it;
|
||||
for (it = path_list.begin(); it != path_list.end(); it++) {
|
||||
if ((*it).id == path->id) {
|
||||
for (unsigned int i = 0; i < path_list.size(); i++) {
|
||||
if (&path_list[i] == path) {
|
||||
libsaria::notify(PATH_DELETED, path);
|
||||
path_list.erase(it);
|
||||
path_list.erase(path_list.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -122,9 +121,8 @@ namespace libsaria
|
|||
|
||||
void library::update_all()
|
||||
{
|
||||
list<Path>::iterator it;
|
||||
for (it = path_list.begin(); it != path_list.end(); it++)
|
||||
do_update_path(&(*it));
|
||||
for (unsigned int i = 0; i < path_list.size(); i++)
|
||||
do_update_path(&path_list[i]);
|
||||
}
|
||||
|
||||
void library::hide_path(Path *path)
|
||||
|
@ -150,17 +148,12 @@ namespace libsaria
|
|||
|
||||
Track *library::lookup(unsigned int libid, unsigned int trackid)
|
||||
{
|
||||
list<Path>::iterator p_it;
|
||||
ListItem<Track> *track;
|
||||
|
||||
for (p_it = path_list.begin(); p_it != path_list.end(); p_it++) {
|
||||
if (p_it->id == libid)
|
||||
break;
|
||||
}
|
||||
if (p_it == path_list.end())
|
||||
if (libid >= path_list.size())
|
||||
return NULL;
|
||||
|
||||
track = p_it->tracks.find_item(check_trackid, &trackid);
|
||||
track = path_list[libid].tracks.find_item(check_trackid, &trackid);
|
||||
if (track == NULL)
|
||||
return NULL;
|
||||
return &track->get_value();
|
||||
|
|
Loading…
Reference in New Issue