From 501b2708903b3a8d495ed4c8c215d971e5fa87cb Mon Sep 17 00:00:00 2001 From: Quantum Date: Sat, 10 Jul 2021 19:07:43 -0400 Subject: [PATCH] [host] nvfbc: optimize change detection loop Before, we only break out of the current row when a change is detected, and all subsequent rows are still scanned. Now we break out of the entire loop. This should make change detection ever so slightly faster. --- host/platform/Windows/capture/NVFBC/src/nvfbc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/host/platform/Windows/capture/NVFBC/src/nvfbc.c b/host/platform/Windows/capture/NVFBC/src/nvfbc.c index 36f36c82..ebeffd35 100644 --- a/host/platform/Windows/capture/NVFBC/src/nvfbc.c +++ b/host/platform/Windows/capture/NVFBC/src/nvfbc.c @@ -165,7 +165,7 @@ static bool nvfbc_init(void) privDataLen = (bufferLen - 1) / 2; privData = (uint8_t *)malloc(privDataLen); char hex[3] = {0}; - for(int i = 0; i < privDataLen; ++i) + for (int i = 0; i < privDataLen; ++i) { memcpy(hex, &buffer[i*2], 2); privData[i] = (uint8_t)strtoul(hex, NULL, 16); @@ -300,14 +300,15 @@ static CaptureResult nvfbc_capture(void) bool changed = false; const unsigned int h = (this->height + 127) / 128; const unsigned int w = (this->width + 127) / 128; - for(unsigned int y = 0; y < h; ++y) - for(unsigned int x = 0; x < w; ++x) + for (unsigned int y = 0; y < h; ++y) + for (unsigned int x = 0; x < w; ++x) if (this->diffMap[(y*w)+x]) { changed = true; - break; + goto done; } +done: if (!changed) return CAPTURE_RESULT_TIMEOUT;