From 41142dff20d8d00c98cd05b901a76280a8ce1d7f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 15 Aug 2020 00:27:07 +0200 Subject: [PATCH] Make a minor optimization in Mac wxDisplay::GetFromWindow() Call GetContentScaleFactor() only once, which doesn't cost anything and could be minutely faster on systems with multiple displays. --- src/osx/core/display.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/osx/core/display.cpp b/src/osx/core/display.cpp index 0a0296259b..06f968edc9 100644 --- a/src/osx/core/display.cpp +++ b/src/osx/core/display.cpp @@ -255,11 +255,12 @@ int wxDisplayFactoryMacOSX::GetFromWindow(const wxWindow *window) err = CGGetDisplaysWithRect(r, theCount, theIDs.get(), &theCount); wxASSERT(err == CGDisplayNoErr); + const double scaleWindow = tlw->GetContentScaleFactor(); for ( int i = 0 ; i < theCount; ++i ) { // find a screen intersecting having the same contentScale as the window itself double scale = wxGetScaleFactor(theIDs[i]); - if ( fabs(scale - tlw->GetContentScaleFactor() ) < 0.01 ) + if ( fabs(scale - scaleWindow) < 0.01 ) { return wxOSXGetDisplayFromID(theIDs[i]); }