aboutsummaryrefslogtreecommitdiffstats
path: root/src/sls.cpp
diff options
context:
space:
mode:
authorStefan Pöschel <github@basicmaster.de>2018-12-08 20:36:46 +0100
committerStefan Pöschel <github@basicmaster.de>2018-12-08 20:38:56 +0100
commit868f00fd98bbc8b2f9c841416d06ac5e61ed7932 (patch)
tree0528aaef9930d3433b64ab99e6bb77bc174f9fd4 /src/sls.cpp
parent295c47a090c16699ec22dd857b828950b49dac6a (diff)
downloadODR-PadEnc-868f00fd98bbc8b2f9c841416d06ac5e61ed7932.tar.gz
ODR-PadEnc-868f00fd98bbc8b2f9c841416d06ac5e61ed7932.tar.bz2
ODR-PadEnc-868f00fd98bbc8b2f9c841416d06ac5e61ed7932.zip
Use range-based for loop where possible
Diffstat (limited to 'src/sls.cpp')
-rw-r--r--src/sls.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/sls.cpp b/src/sls.cpp
index 4cb7848..f19829f 100644
--- a/src/sls.cpp
+++ b/src/sls.cpp
@@ -36,13 +36,10 @@ const int History::MAXSLIDEID = 9999; // Roll-over value for fidx
int History::find(const fingerprint_t& fp) const
{
- size_t i;
- for (i = 0; i < m_database.size(); i++) {
- if (m_database[i] == fp) {
- // return the id of fingerprint found
- return m_database[i].fidx;
- }
- }
+ // return the id of fingerprint found
+ for (const fingerprint_t& db_fp : m_database)
+ if (db_fp == fp)
+ return db_fp.fidx;
// return -1 when the database doesn't contain this fingerprint
return -1;
@@ -124,13 +121,13 @@ bool SlideStore::InitFromDir(const std::string& dir) {
struct dirent** dir_entries;
int dir_count = scandir(dir.c_str(), &dir_entries, FilterSlides, alphasort);
- if(dir_count < 0) {
+ if (dir_count < 0) {
perror(("ODR-PadEnc Error: cannot open slides directory '" + dir + "'").c_str());
return false;
}
// add new slides to transmit to list
- for(int i = 0; i < dir_count; i++) {
+ for (int i = 0; i < dir_count; i++) {
std::string imagepath = dir + "/" + std::string(dir_entries[i]->d_name);
free(dir_entries[i]);