core/database: Remove database::size() function

We can just use the db_size variable directly.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-10-17 14:59:06 -04:00
parent 8a4e9fc2bc
commit 1dcbc0c505
8 changed files with 17 additions and 30 deletions

View File

@ -156,13 +156,6 @@ struct database {
*/
void remove(unsigned int);
/**
* Called to find the number of valid items in the Database.
*
* @return Database::_size
*/
unsigned int size();
/**
* Called to find the size of the backing std::vector.
*

View File

@ -112,12 +112,6 @@ void database<T> :: remove(unsigned int index)
autosave();
}
template <class T>
unsigned int database<T> :: size()
{
return db_size;
}
template <class T>
unsigned int database<T> :: actual_size()
{
@ -127,7 +121,7 @@ unsigned int database<T> :: actual_size()
template <class T>
typename database<T>::iterator database<T> :: begin()
{
if (size() == 0)
if (db_size == 0)
return end();
iterator it = db_entries.begin();

View File

@ -65,7 +65,7 @@ static void test_init()
/* Check initial sizes. */
test_equal(db.actual_size(), 0);
test_equal(db.size(), 0);
test_equal(db.db_size, 0);
}
static void test_stress(unsigned int N)
@ -87,7 +87,7 @@ static void test_stress(unsigned int N)
ptrs.push_back(dbe);
} test_loop_passed();
test_equal(db.size(), N);
test_equal(db.db_size, N);
test_equal(db.actual_size(), N);
/* database.at() */
@ -123,7 +123,7 @@ static void test_stress(unsigned int N)
g_free(key);
} test_loop_passed();
db.remove(N);
test_equal(db.size(), N / 2);
test_equal(db.db_size, N / 2);
test_equal(db.actual_size(), N);
/* database.first(), database.next(), database.end() */
@ -154,7 +154,7 @@ static void test_save_load()
db1.insert(int_entry(i));
db2.load();
test_equal(db2.size(), N);
test_equal(db2.db_size, N);
test_equal(db2.actual_size(), N);
for (i = 0; i < N; i++) {
dbe = db2.at(i);
@ -168,7 +168,7 @@ static void test_save_load()
db2 = database<struct int_entry>("save_load.db", false);
db2.load();
test_equal(db2.size(), N / 2);
test_equal(db2.db_size, N / 2);
for (i = 1; i < N; i++) {
dbe = db2.at(i);
if ((i % 2) == 0) {
@ -187,13 +187,13 @@ static void test_save_load()
db1 = database<struct int_entry>("save_load.db", false);
db1.load();
test_equal(db1.size(), N / 2);
test_equal(db1.db_size, N / 2);
db2.save();
db1 = database<struct int_entry>("save_load.db", false);
db1.load();
test_equal(db1.size(), N);
test_equal(db1.db_size, N);
test_equal(db1.actual_size(), 2 * N);
for (i = 1; i < (2 * N); i++) {
dbe = db1.at(i);

View File

@ -19,12 +19,12 @@ static void test_single_item()
IndexEntry *it = index.find("a");
test_not_equal(it, (IndexEntry *)NULL);
test_equal(index.size(), (unsigned)1);
test_equal(index.db_size, (unsigned)1);
test_equal(it->size(), (size_t)1);
test_equal(*(it->begin()), (unsigned)0);
index.remove("a", 0);
test_equal(index.size(), (unsigned)1);
test_equal(index.db_size, (unsigned)1);
test_equal(it->size(), (size_t)0);
}
@ -39,7 +39,7 @@ static void test_insertion(unsigned int n)
INDEX->insert(std::string(1, c), i);
}
test_equal(INDEX->size(), (n == 0) ? 0 : 26);
test_equal(INDEX->db_size, (n == 0) ? 0 : 26);
for (char c = 'a'; c <= 'z'; c++) {
IndexEntry *it = INDEX->find(std::string(1, c));
@ -78,12 +78,12 @@ static void test_save_load(unsigned int n)
IndexEntry *it1, *it2;
idx2.load();
test_equal(idx2.size(), (unsigned)0);
test_equal(idx2.db_size, (unsigned)0);
INDEX->save();
idx2.load();
test_equal(idx2.size(), INDEX->size());
test_equal(idx2.db_size, INDEX->db_size);
test_equal(idx2.actual_size(), INDEX->actual_size());
for (char c = 'a'; c <= 'z'; c++) {

View File

@ -50,7 +50,7 @@ static void test_album_tag_lookup()
test_equal(tags :: get_album(1), (Album *)NULL);
album_db.load();
test_equal(album_db.size(), (unsigned)1);
test_equal(album_db.db_size, (unsigned)1);
}
DECLARE_UNIT_TESTS(

View File

@ -31,7 +31,7 @@ static void test_artist_tag_lookup()
test_equal(tags :: get_artist(1), (Artist *)NULL);
artist_db.load();
test_equal(artist_db.size(), (unsigned)1);
test_equal(artist_db.db_size, (unsigned)1);
}
DECLARE_UNIT_TESTS(

View File

@ -31,7 +31,7 @@ static void test_genere_tag_lookup()
test_equal(tags :: get_genre(1), (Genre *)NULL);
genre_db.load();
test_equal(genre_db.size(), (unsigned)1);
test_equal(genre_db.db_size, (unsigned)1);
}
DECLARE_UNIT_TESTS(

View File

@ -109,7 +109,7 @@ static void test_track_tag_load_db(unsigned int size)
{
database<Track> track_db("track.db", false);
track_db.load();
test_equal(track_db.size(), size);
test_equal(track_db.db_size, size);
}
static void test_track_tag_lookup()