Skip to content

Commit 286c33f

Browse files
committed
Rename hash and simplify comparison
1 parent e1380db commit 286c33f

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

DBAPI.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,24 +224,18 @@ DBdeparr* DBAPI::getStationBoard(
224224
return deparr;
225225
}
226226

227-
uint8_t hash[20];
227+
uint8_t current_hash[20];
228228
// hash to save RAM as the ID is >150 chars
229-
sha1(doc["zuglaufId"].as<String>(), hash);
229+
sha1(doc["zuglaufId"].as<String>(), current_hash);
230230

231231
bool match = false;
232232
for (uint8_t i = 0; i < cnt && !match; i++) {
233-
bool mismatch = false;
234-
for (uint8_t j = 0; j < 20; j++) {
235-
if (hashes[i][j] != hash[j]) {
236-
mismatch = true;
237-
break;
238-
}
239-
match |= !mismatch;
240-
}
233+
match |= !memcmp(hashes[i], current_hash, sizeof(current_hash));
241234
}
242235
// duplicate entry found, skipping
243236
if (match) continue;
244237
memcpy(hashes[cnt], hash, sizeof(hash));
238+
memcpy(hashes[cnt], current_hash, sizeof(current_hash));
245239

246240
DBdeparr* da = new DBdeparr();
247241
String targ = doc[abfahrt?"richtung":"abgangsOrt"];

0 commit comments

Comments
 (0)