summaryrefslogtreecommitdiff
path: root/shared/zstring.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:14:37 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:14:37 +0200
commit8bf668665b107469086f16cb8ad23e47d479d2b4 (patch)
tree66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /shared/zstring.cpp
parent3.21 (diff)
downloadFreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz
FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2
FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip
4.0
Diffstat (limited to 'shared/zstring.cpp')
-rw-r--r--shared/zstring.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/shared/zstring.cpp b/shared/zstring.cpp
index e1df17ee..45762000 100644
--- a/shared/zstring.cpp
+++ b/shared/zstring.cpp
@@ -107,25 +107,25 @@ bool hasInvariantLocale()
const LCID ZSTRING_INVARIANT_LOCALE = hasInvariantLocale() ?
LOCALE_INVARIANT :
MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); //see: http://msdn.microsoft.com/en-us/goglobal/bb688122.aspx
+
+
+//try to call "CompareStringOrdinal" for low-level string comparison: unfortunately available not before Windows Vista!
+//by a factor ~3 faster than old string comparison using "LCMapString"
+typedef int (WINAPI* CompareStringOrdinalFunc)(LPCWSTR lpString1,
+ int cchCount1,
+ LPCWSTR lpString2,
+ int cchCount2,
+ BOOL bIgnoreCase);
+util::DllFun<CompareStringOrdinalFunc> ordinalCompare; //caveat: function scope static initialization is not thread-safe in VS 2010!
+boost::once_flag initCmpStrOrdOnce = BOOST_ONCE_INIT;
}
int z_impl::compareFilenamesWin(const wchar_t* a, const wchar_t* b, size_t sizeA, size_t sizeB)
{
- //try to call "CompareStringOrdinal" for low-level string comparison: unfortunately available not before Windows Vista!
- //by a factor ~3 faster than old string comparison using "LCMapString"
- typedef int (WINAPI *CompareStringOrdinalFunc)(
- LPCWSTR lpString1,
- int cchCount1,
- LPCWSTR lpString2,
- int cchCount2,
- BOOL bIgnoreCase);
- static CompareStringOrdinalFunc ordinalCompare = NULL; //caveat: function scope static initialization is not thread-safe in VS 2010!
- static boost::once_flag once = BOOST_ONCE_INIT;
- boost::call_once(once, []() { ordinalCompare = util::getDllFun<CompareStringOrdinalFunc>(L"kernel32.dll", "CompareStringOrdinal"); });
-
-
- if (ordinalCompare != NULL) //this additional test has no noticeable performance impact
+ boost::call_once(initCmpStrOrdOnce, []() { ordinalCompare = util::DllFun<CompareStringOrdinalFunc>(L"kernel32.dll", "CompareStringOrdinal"); });
+
+ if (ordinalCompare) //this additional test has no noticeable performance impact
{
const int rv = ordinalCompare(a, //pointer to first string
static_cast<int>(sizeA), //size, in bytes or characters, of first string
bgstack15