From 4e65425c007288ea238194e8ab76d7128b2ac64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 30 Jan 2022 14:41:29 +0100 Subject: [PATCH] Cleanup --- GRDB/Core/Database+Statements.swift | 4 ++-- GRDB/Core/TransactionObserver.swift | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GRDB/Core/Database+Statements.swift b/GRDB/Core/Database+Statements.swift index 48033e38f..7a263d041 100644 --- a/GRDB/Core/Database+Statements.swift +++ b/GRDB/Core/Database+Statements.swift @@ -639,7 +639,7 @@ struct StatementCache { statements.removeFirst { $0.value === statement } } - mutating func clear(where isDeleted: (Statement) -> Bool) { - statements = statements.filter { (_, statement) in !isDeleted(statement) } + mutating func removeAll(where shouldBeRemoved: (Statement) -> Bool) { + statements = statements.filter { (_, statement) in !shouldBeRemoved(statement) } } } diff --git a/GRDB/Core/TransactionObserver.swift b/GRDB/Core/TransactionObserver.swift index 4481265c4..f9a0d6cd8 100644 --- a/GRDB/Core/TransactionObserver.swift +++ b/GRDB/Core/TransactionObserver.swift @@ -17,8 +17,8 @@ extension Database { // Drop cached statements that delete, this the addition of an // observer may change the need for truncate optimization prevention. - publicStatementCache.clear(where: { $0.databaseEventKinds.contains(where: \.isDelete) }) - internalStatementCache.clear(where: { $0.databaseEventKinds.contains(where: \.isDelete) }) + publicStatementCache.removeAll { $0.databaseEventKinds.contains(where: \.isDelete) } + internalStatementCache.removeAll{ $0.databaseEventKinds.contains(where: \.isDelete) } observationBroker.add(transactionObserver: transactionObserver, extent: extent) } @@ -29,8 +29,8 @@ extension Database { // Drop cached statements that delete, this the removal of an // observer may change the need for truncate optimization prevention. - publicStatementCache.clear(where: { $0.databaseEventKinds.contains(where: \.isDelete) }) - internalStatementCache.clear(where: { $0.databaseEventKinds.contains(where: \.isDelete) }) + publicStatementCache.removeAll { $0.databaseEventKinds.contains(where: \.isDelete) } + internalStatementCache.removeAll { $0.databaseEventKinds.contains(where: \.isDelete) } observationBroker.remove(transactionObserver: transactionObserver) }