Reworked deleting old message using removeIf instead of in a loop.
This commit is contained in:
parent
7ff30c1ce8
commit
48a6c29fc9
1 changed files with 1 additions and 10 deletions
|
@ -75,17 +75,8 @@ final class TellMessagesMgr {
|
|||
*/
|
||||
static boolean clean(final List<TellMessage> tellMessages, final int tellMaxDays) {
|
||||
final LocalDateTime today = LocalDateTime.now(Clock.systemUTC());
|
||||
boolean cleaned = false;
|
||||
|
||||
for (final TellMessage message : tellMessages) {
|
||||
final LocalDateTime maxDate = message.getQueued().plusDays(tellMaxDays);
|
||||
if (maxDate.isBefore(today)) {
|
||||
tellMessages.remove(message);
|
||||
cleaned = true;
|
||||
}
|
||||
}
|
||||
|
||||
return cleaned;
|
||||
return tellMessages.removeIf(o -> o.getQueued().plusDays(tellMaxDays).isBefore(today));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue