From a3322cb171fed42bc3d15adc84d03cf560fc0fc9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 27 Jan 2013 18:30:36 +0100 Subject: osx_common: cache OSX version number This commit makes `is_osx_version_at_least` cache the result of reading `/System/Library/CoreServices/SystemVersion.plist`. Since that is a file read operation it was bad to use this function frequently (i.e.: when processing user events). Remove `is_lion_or_above` (introduced in c9396c0a) as that was a more specialized wrapper which had the only advantage of adding it's own cache. --- video/out/cocoa_common.m | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 217321d593..27f8380112 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -147,20 +147,10 @@ static struct vo_cocoa_state *vo_cocoa_init_state(struct vo *vo) return s; } -static bool is_lion_or_above() -{ - static bool result = false, checked = false; - if (!checked) { - result = is_osx_version_at_least(10, 7, 0); - checked = true; - } - return result; -} - static bool supports_hidpi(NSView *view) { SEL hdpi_selector = @selector(setWantsBestResolutionOpenGLSurface:); - return is_lion_or_above() && view && + return is_osx_version_at_least(10, 7, 0) && view && [view respondsToSelector:hdpi_selector]; } @@ -765,7 +755,8 @@ void create_menu() delta = - [theEvent deltaX]; } - if (is_lion_or_above() && [theEvent hasPreciseScrollingDeltas]) { + if (is_osx_version_at_least(10, 7, 0) && + [theEvent hasPreciseScrollingDeltas]) { s->accumulated_scroll += delta; static const CGFloat threshold = 10; while (s->accumulated_scroll >= threshold) { -- cgit v1.2.3