1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

MCOL-3419 Get rid of std::locale::global() from MCOL-1559.

This commit is contained in:
David Hall
2019-08-13 15:20:28 -05:00
parent 29f7516eec
commit fd373dfbfb
2 changed files with 7 additions and 5 deletions

View File

@ -46,6 +46,9 @@ namespace funcexp
{ {
namespace utf8 namespace utf8
{ {
// A global loc object so we don't construct one at every compare
std::locale loc;
bool JPcodePoint = false; // extern-ed in utils_utf8.h bool JPcodePoint = false; // extern-ed in utils_utf8.h
} }

View File

@ -36,7 +36,6 @@
#include <cstdlib> #include <cstdlib>
#include <clocale> #include <clocale>
#include "alarmmanager.h" #include "alarmmanager.h"
using namespace alarmmanager; using namespace alarmmanager;
@ -55,7 +54,7 @@ extern bool JPcodePoint; // code point ordering (Japanese UTF) flag, used in id
const int MAX_UTF8_BYTES_PER_CHAR = 4; const int MAX_UTF8_BYTES_PER_CHAR = 4;
// A global loc object so we don't construct one at every compare // A global loc object so we don't construct one at every compare
static std::locale loc; extern std::locale loc;
// Is there a way to construct a global reference to a facet? // Is there a way to construct a global reference to a facet?
// const std::collate<char>& coll = std::use_facet<std::collate<char> >(loc); // const std::collate<char>& coll = std::use_facet<std::collate<char> >(loc);
@ -79,8 +78,6 @@ std::string idb_setlocale()
} }
char* pLoc = setlocale(LC_ALL, systemLang.c_str()); char* pLoc = setlocale(LC_ALL, systemLang.c_str());
// MCOL-1559 also set the C++ locale
std::locale::global(std::locale(pLoc));
if (pLoc == NULL) if (pLoc == NULL)
{ {
@ -121,7 +118,8 @@ std::string idb_setlocale()
if (systemLang.find("ja_JP") != std::string::npos) if (systemLang.find("ja_JP") != std::string::npos)
JPcodePoint = true; JPcodePoint = true;
std::locale localloc; // MCOL-1559 Save off the locale to save runtime cpus
std::locale localloc(systemLang.c_str());
loc = localloc; loc = localloc;
return systemLang; return systemLang;
@ -148,6 +146,7 @@ int idb_strtrimcoll(const std::string& str1, const std::string& str2)
static const std::string whitespaces (" "); static const std::string whitespaces (" ");
const char* s1 = str1.c_str(); const char* s1 = str1.c_str();
const char* s2 = str2.c_str(); const char* s2 = str2.c_str();
// Set found1 to the last non-whitespace char in str1 // Set found1 to the last non-whitespace char in str1
std::size_t found1 = str1.find_last_not_of(whitespaces); std::size_t found1 = str1.find_last_not_of(whitespaces);
// Set found2 to the first whitespace char in str2 // Set found2 to the first whitespace char in str2