summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MdeModulePkg/Core/Dxe/Gcd/Gcd.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index 467d5e4813..f5cac1874a 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -153,6 +153,13 @@ CoreDumpGcdMemorySpaceMap (
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
UINTN Index;
+ // The compiler is not smart enough to compile out the whole function if DEBUG_GCD is not enabled, so we end up
+ // looping through the GCD every time it gets updated, which wastes a lot of needless cycles if we aren't going to
+ // print it. So shortcircuit and jump out if we don't need to print it.
+ if (!DebugPrintLevelEnabled (DEBUG_GCD)) {
+ return;
+ }
+
Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
ASSERT (Status == EFI_SUCCESS && MemorySpaceMap != NULL);
@@ -199,6 +206,13 @@ CoreDumpGcdIoSpaceMap (
EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap;
UINTN Index;
+ // The compiler is not smart enough to compile out the whole function if DEBUG_GCD is not enabled, so we end up
+ // looping through the GCD every time it gets updated, which wastes a lot of needless cycles if we aren't going to
+ // print it. So shortcircuit and jump out if we don't need to print it.
+ if (!DebugPrintLevelEnabled (DEBUG_GCD)) {
+ return;
+ }
+
Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);
ASSERT (Status == EFI_SUCCESS && IoSpaceMap != NULL);