perf: SimpleDataStore

This commit is contained in:
Bobby Wibowo 2022-07-03 11:00:48 +07:00
parent 8a1ff434d9
commit 39aaa25f3f
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -52,14 +52,14 @@ class SimpleDataStore {
}
getStalest () {
let stalest = null
let stalest = [null, { stratval: Infinity }]
switch (this.#strategy) {
// both "lastGetTime" and "getsCount" simply must find lowest value
// to determine the stalest entry
case STRATEGIES[0]:
case STRATEGIES[1]:
for (const entry of this.#store) {
if (!stalest || entry[1].stratval < stalest[1].stratval) {
if (entry[1].stratval < stalest[1].stratval) {
stalest = entry
}
}