Merge branch 'main' of http://100.103.83.12:3003/fegger/soundServe
This commit is contained in:
@@ -53,8 +53,8 @@ class HashTable {
|
||||
HashTable ( HashTable && ) noexcept = default;
|
||||
HashTable &operator= ( HashTable && ) noexcept = default;
|
||||
|
||||
void ht_insert ( const std::string &key, Track* t );
|
||||
Track* ht_lookup ( const std::string &key ) const;
|
||||
void ht_insert ( const std::string &key, std::shared_ptr<Track> t );
|
||||
std::shared_ptr<Track> ht_lookup ( const std::string &key ) const;
|
||||
bool ht_delete ( const std::string &key );
|
||||
|
||||
std::vector<std::string> listAll () const;
|
||||
@@ -72,7 +72,7 @@ class HashTable {
|
||||
struct Entry {
|
||||
std::string key;
|
||||
uint64_t hash = 0;
|
||||
Track* track;
|
||||
std::shared_ptr<Track> track;
|
||||
};
|
||||
|
||||
// helpers
|
||||
|
||||
+2
-2
@@ -108,7 +108,7 @@ std::ptrdiff_t ht::probe ( const std::string &key, uint64_t hash, bool insert )
|
||||
#endif
|
||||
} // probe
|
||||
|
||||
void ht::ht_insert( const std::string& key, Track* t ) {
|
||||
void ht::ht_insert( const std::string& key, std::shared_ptr<Track> t ) {
|
||||
//double loadFactor = static_cast<double> ( size_ ) / static_cast<double> ( ctrl_.size());
|
||||
|
||||
if ( loadFactor_ > MAX_LOAD ) rehash( ctrl_.size() * 2 );
|
||||
@@ -129,7 +129,7 @@ void ht::ht_insert( const std::string& key, Track* t ) {
|
||||
ctrl_.at( idx ) = fingerprint( hash );
|
||||
}
|
||||
|
||||
Track* ht::ht_lookup( const std::string& key ) const {
|
||||
std::shared_ptr<Track> ht::ht_lookup( const std::string& key ) const {
|
||||
uint64_t hash = hashString( key );
|
||||
auto idx = probe( key, hash, false );
|
||||
if ( idx != -1 ) return entries_.at( static_cast<std::size_t> ( idx )).track;
|
||||
|
||||
+3
-3
@@ -60,8 +60,8 @@ void PlayerLocal::scanLibrary(){
|
||||
void PlayerLocal::loadLibrary() {
|
||||
db_.fetchAll( library );
|
||||
for ( auto t : library ) {
|
||||
tracks_.ht_insert(t.title.toCString(), &t );
|
||||
artists_.ht_insert( t.artist.toCString(), &t );
|
||||
albums_.ht_insert( t.album.toCString(), &t );
|
||||
tracks_.ht_insert(t.title.toCString(), std::make_shared<Track> (t) );
|
||||
artists_.ht_insert( t.artist.toCString(), std::make_shared<Track> (t) );
|
||||
albums_.ht_insert( t.album.toCString(), std::make_shared<Track> (t) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user