From fb265b610de08df5509e56beeb3dbff68f7d4396 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 24 Aug 2021 15:07:15 +0200 Subject: Android: Don't hold gameFileCache lock during updateAdditionalMetadata It seems like we spend a lot of the game list scanning time in updateAdditionalMetadata, which I suppose makes sense considering how many different files that function attempts to open. With the addition of just one little atomic operation, we can make it safe to call updateAdditionalMetadata without holding a lock. --- .../dolphinemu/services/GameFileCacheService.java | 37 +++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'Source/Android/app/src/main/java') diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheService.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheService.java index 1a9284a9c4..a8ecc367c9 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheService.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/GameFileCacheService.java @@ -194,26 +194,27 @@ public final class GameFileCacheService extends IntentService { String[] gamePaths = GameFileCache.getAllGamePaths(); + boolean changed; synchronized (gameFileCache) { - boolean changed = gameFileCache.update(gamePaths); - if (changed) - { - updateGameFileArray(); - sendBroadcast(CACHE_UPDATED); - } - - boolean additionalMetadataChanged = gameFileCache.updateAdditionalMetadata(); - if (additionalMetadataChanged) - { - updateGameFileArray(); - sendBroadcast(CACHE_UPDATED); - } - - if (changed || additionalMetadataChanged) - { - gameFileCache.save(); - } + changed = gameFileCache.update(gamePaths); + } + if (changed) + { + updateGameFileArray(); + sendBroadcast(CACHE_UPDATED); + } + + boolean additionalMetadataChanged = gameFileCache.updateAdditionalMetadata(); + if (additionalMetadataChanged) + { + updateGameFileArray(); + sendBroadcast(CACHE_UPDATED); + } + + if (changed || additionalMetadataChanged) + { + gameFileCache.save(); } } -- cgit v1.2.3