diff --git a/uppsrc/Core/Convert.h b/uppsrc/Core/Convert.h index 7f8a73787..bbd97dc6e 100644 --- a/uppsrc/Core/Convert.h +++ b/uppsrc/Core/Convert.h @@ -299,3 +299,5 @@ private: public: void SetFormat(const char *fmt) { format = fmt; } }; + +Convert& LNGConvert(); diff --git a/uppsrc/Core/Core.h b/uppsrc/Core/Core.h index 3ecba50ec..db185c00a 100644 --- a/uppsrc/Core/Core.h +++ b/uppsrc/Core/Core.h @@ -299,6 +299,8 @@ class JsonIO; #include "Other.h" +#include "Lang.h" + #include "Value.h" #include "ValueUtil.h" @@ -332,7 +334,6 @@ class JsonIO; #include "Xmlize.h" #include "Gtypes.h" -#include "Lang.h" #include "i18n.h" #include "Topic.h" diff --git a/uppsrc/Core/Lang.cpp b/uppsrc/Core/Lang.cpp index 51b8a7166..379c12990 100644 --- a/uppsrc/Core/Lang.cpp +++ b/uppsrc/Core/Lang.cpp @@ -156,6 +156,10 @@ void SetLanguage(int lang) { SetCurrentLanguage(lang); } +INITBLOCK { + SetLanguage(LNG_('E', 'N', 'U', 'S')); +} + void SetLanguage(const char *s) { SetLanguage(LNGFromText(s)); diff --git a/uppsrc/Core/Lang.h b/uppsrc/Core/Lang.h index c17bda075..673fffe6e 100644 --- a/uppsrc/Core/Lang.h +++ b/uppsrc/Core/Lang.h @@ -8,8 +8,6 @@ int LNGFromText(const char *s); String LNGAsText(int d); -Convert& LNGConvert(); - byte GetLNGCharset(int d); int SetLNGCharset(int lng, byte chrset); @@ -111,3 +109,5 @@ struct LangTextRecord { void AddLangModule(const char *file, const char *modulename, int masterlang, const LangModuleRecord *module); void AddLanguage(const char *modulename, int lang, const LangTextRecord *langtext); + +void SyncLngInfo__(); diff --git a/uppsrc/Core/LangInfo.cpp b/uppsrc/Core/LangInfo.cpp index e5895c382..ecc606abc 100644 --- a/uppsrc/Core/LangInfo.cpp +++ b/uppsrc/Core/LangInfo.cpp @@ -468,6 +468,8 @@ ArrayMap& LangMap() StaticMutex sLanguageInfoMutex; +static std::atomic sCurrentLangInfo; + const LanguageInfo& GetLanguageInfo(int lang) { Mutex::Lock __(sLanguageInfoMutex); @@ -483,9 +485,16 @@ const LanguageInfo& GetLanguageInfo(int lang) return f; } +void SyncLngInfo__() +{ + sCurrentLangInfo = &GetLanguageInfo(GetCurrentLanguage()); +} + const LanguageInfo& GetLanguageInfo() { - return GetLanguageInfo(GetCurrentLanguage()); + if(!sCurrentLangInfo) + SyncLngInfo__(); + return *sCurrentLangInfo; } void SetLanguageInfo(int lang, const LanguageInfo& lf) diff --git a/uppsrc/Core/Mt.h b/uppsrc/Core/Mt.h index 4961004b3..9ced1d19a 100644 --- a/uppsrc/Core/Mt.h +++ b/uppsrc/Core/Mt.h @@ -1,9 +1,3 @@ -#ifndef _DEBUG -inline void AssertST() {} -#endif - -#ifdef _MULTITHREADED - #ifdef DEPRECATED #define thread__ thread_local #endif @@ -114,8 +108,11 @@ private: #ifdef _DEBUG inline void AssertST() { ASSERT(Thread::IsST()); } +#else +inline void AssertST() {} #endif + class Semaphore : NoCopy { #ifdef PLATFORM_WIN32 HANDLE handle; @@ -410,106 +407,6 @@ struct H_l_ : Mutex::Lock { #define INTERLOCKED_(cs) \ for(UPP::H_l_ i_ss_lock__(cs); i_ss_lock__.b; i_ss_lock__.b = false) - -#else - -inline bool IsMainThread() { return true; } - -#define thread__ - -#define PROFILEMT(mutex) -#define PROFILEMT_(mutex, id) - -class Mutex : NoCopy { -public: - bool TryEnter() { return true; } - void Enter() {} - void Leave() {} - - class Lock; -}; - -typedef Mutex StaticMutex; - -class Mutex::Lock : NoCopy { -public: - Lock(Mutex&) {} - ~Lock() {} -}; - -class RWMutex : NoCopy { -public: - void EnterWrite() {} - void LeaveWrite() {} - - void EnterRead() {} - void LeaveRead() {} - - class ReadLock; - class WriteLock; -}; - -class RWMutex::ReadLock : NoCopy { -public: - ReadLock(RWMutex&) {} - ~ReadLock() {} -}; - -class RWMutex::WriteLock : NoCopy { -public: - WriteLock(RWMutex&) {} - ~WriteLock() {} -}; - -typedef RWMutex StaticRWMutex; - -class LazyUpdate { - mutable bool dirty; - -public: - void Invalidate() { dirty = true; } - bool BeginUpdate() const { return dirty; } - void EndUpdate() const { dirty = false; } - - LazyUpdate() { dirty = true; } -}; - -struct SpinLock { - bool TryEnter() { return true; } - void Leave() {} - void Enter() {} - - class Lock; - - SpinLock() {} -}; - -class SpinLock::Lock : NoCopy { -public: - Lock(SpinLock& s) {} - ~Lock() {} -}; - -#ifdef _DEBUG -inline void AssertST() {} -#endif - -#define INTERLOCKED -#define INTERLOCKED_(x) { x.Enter(); } - -#define ONCELOCK \ -for(static bool o_b_; !o_b_; o_b_ = true) - -#define ONCELOCK_(o_b_) \ -for(; !o_b_; o_b_ = true) \ - -#define ONCELOCK_PTR(ptr, init) \ -if(!ptr) ptr = init; - -inline void ReadMemoryBarrier() {} -inline void WriteMemoryBarrier() {} - -#endif #ifdef DEPRECATED typedef Mutex CriticalSection; diff --git a/uppsrc/Core/ValueUtil.cpp b/uppsrc/Core/ValueUtil.cpp index 7ede43559..12029d29d 100644 --- a/uppsrc/Core/ValueUtil.cpp +++ b/uppsrc/Core/ValueUtil.cpp @@ -596,55 +596,6 @@ Value ValueMap::GetAndClear(const Value& key) // ---------------------------------- -int StdValueCompare(const Value& a, const Value& b, int language) -{ - LTIMING("StdValueCompare"); - - bool na = IsNull(a), nb = IsNull(b); - if(na || nb) - return !na ? 1 : !nb ? -1 : 0; - dword ta = a.GetType(), tb = b.GetType(); - if((ta == INT_V || ta == BOOL_V) && (tb == INT_V || tb == BOOL_V)) - return cmp(a, b); - if((ta == BOOL_V || ta == INT_V || ta == INT64_V || ta == DOUBLE_V) - && (tb == BOOL_V || tb == INT_V || tb == INT64_V || tb == DOUBLE_V)) - return cmp(a, b); - if(ta == DATE_V && tb == DATE_V) - return cmp(a, b); - if((ta == DATE_V || ta == TIME_V) && (tb == DATE_V || tb == TIME_V)) - return cmp