From b7afbd4bcb92349090bdf04b971bf1cb2b1440fd Mon Sep 17 00:00:00 2001 From: Andreas Mohr Date: Mon, 1 Oct 2001 20:52:37 +0000 Subject: [PATCH] Speed optimization. --- misc/version.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/misc/version.c b/misc/version.c index cfefc381610..06989167a94 100644 --- a/misc/version.c +++ b/misc/version.c @@ -358,18 +358,26 @@ DWORD VERSION_GetLinkedDllVersion(void) */ static WINDOWS_VERSION VERSION_GetVersion(void) { - static WORD winver = 0xffff; + static WORD winver = 0xffff; - if (versionForced) /* user has overridden any sensible checks */ - return defaultWinVersion; + if (winver == 0xffff) /* to be determined */ + { + WINDOWS_VERSION retver; + + if (versionForced) /* user has overridden any sensible checks */ + winver = defaultWinVersion; + else + { + retver = VERSION_GetLinkedDllVersion(); - if (winver == 0xffff) /* to be determined */ { - WINDOWS_VERSION retver = VERSION_GetLinkedDllVersion(); + /* cache determined value, but do not store in case of WIN31 */ + if (retver != WIN31) winver = retver; - if (retver != WIN31) winver = retver; - return retver; + return retver; } - return winver; + } + + return winver; }