Reworked deleting old message using removeIf instead of in a loop.

This commit is contained in:
Erik C. Thauvin 2019-04-20 05:22:06 -07:00
parent 7ff30c1ce8
commit 48a6c29fc9

View file

@ -75,17 +75,8 @@ final class TellMessagesMgr {
*/ */
static boolean clean(final List<TellMessage> tellMessages, final int tellMaxDays) { static boolean clean(final List<TellMessage> tellMessages, final int tellMaxDays) {
final LocalDateTime today = LocalDateTime.now(Clock.systemUTC()); final LocalDateTime today = LocalDateTime.now(Clock.systemUTC());
boolean cleaned = false;
for (final TellMessage message : tellMessages) { return tellMessages.removeIf(o -> o.getQueued().plusDays(tellMaxDays).isBefore(today));
final LocalDateTime maxDate = message.getQueued().plusDays(tellMaxDays);
if (maxDate.isBefore(today)) {
tellMessages.remove(message);
cleaned = true;
}
}
return cleaned;
} }
/** /**