Skip to content

Commit

Permalink
don't execute code unnecessarily if nothing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Apr 21, 2021
1 parent 4618f7c commit afd4dce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import javax.inject.Singleton
* the undo history */
fun deleteSyncedOlderThan(timestamp: Long): Int {
val edits = editsDB.getSyncedOlderThan(timestamp)
if (edits.isEmpty()) return 0
val result = editsDB.deleteAll(edits.map { it.id })
onDeletedEdits(edits)
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import javax.inject.Singleton

@Synchronized fun deleteSyncedOlderThan(timestamp: Long): Int {
val edits = editsDB.getSyncedOlderThan(timestamp)
if (edits.isEmpty()) return 0
val result = editsDB.deleteAll(edits.map { it.id })
onDeletedEdits(edits)
return result
Expand Down

0 comments on commit afd4dce

Please sign in to comment.