libsaria: Rename the index rand() function
I found it was calling itself over and over again, rather than calling the stdlib rand(). This wasn't the desired behavior... Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
d00ed2ebdc
commit
51e5887971
|
@ -3,7 +3,7 @@ import sys
|
|||
|
||||
MAJOR = 5
|
||||
MINOR = 5
|
||||
BUG = 0
|
||||
BUG = 1
|
||||
EXTRA = ""
|
||||
DEBUG = False
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace libsaria
|
|||
bool is_visible(sid_t &);
|
||||
bool is_filtered();
|
||||
unsigned int size();
|
||||
sid_t rand();
|
||||
sid_t rand_id();
|
||||
void print_stats();
|
||||
|
||||
}; /* Namespace: index */
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
using namespace std;
|
||||
|
||||
map<string, set<sid_t> > artist_index;
|
||||
|
@ -97,10 +98,11 @@ namespace libsaria
|
|||
println("Index cache hits: %u size: %u", hits, substr_cache.size());
|
||||
}
|
||||
|
||||
sid_t index::rand()
|
||||
sid_t index::rand_id()
|
||||
{
|
||||
set<sid_t>::iterator it = results.begin();
|
||||
unsigned int index = rand() % results.size();
|
||||
println("results.size()? %d", results.size());
|
||||
|
||||
for (unsigned int i = 0; i < index; i++)
|
||||
it++;
|
||||
|
|
|
@ -31,7 +31,7 @@ static void find_id(sid_t songid)
|
|||
static void random_next()
|
||||
{
|
||||
if (libsaria::index::is_filtered())
|
||||
find_id( libsaria::index::rand() );
|
||||
find_id( libsaria::index::rand_id() );
|
||||
else {
|
||||
unsigned int n = rand() % track_list.size();
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
|
|
Loading…
Reference in New Issue