From fc35803f9108711a1ba0e41cfe252ed74efca8a4 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Tue, 14 Apr 2020 13:55:19 -0400
Subject: [PATCH] file_sys: patch_manager: Return early when there are no
 layers to apply.

---
 src/core/file_sys/patch_manager.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index e226e9711..e77e82b8d 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -348,6 +348,12 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t
         if (ext_dir != nullptr)
             layers_ext.push_back(std::move(ext_dir));
     }
+
+    // When there are no layers to apply, return early as there is no need to rebuild the RomFS
+    if (layers.empty() && layers_ext.empty()) {
+        return;
+    }
+
     layers.push_back(std::move(extracted));
 
     auto layered = LayeredVfsDirectory::MakeLayeredDirectory(std::move(layers));