Data type registrator went the same way - using plain statics instead of in-place allocation at first call. For code size critical applications, GCC flag -fno-threadsafe-statics should be used

This commit is contained in:
Pavel Kirienko
2014-04-20 23:40:32 +04:00
parent 7a02960401
commit f155702008
@@ -139,39 +139,23 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::regist(DataTypeID i
{
return RegistResultFrozen;
}
static union
static Entry entry;
{
uint8_t buffer[sizeof(Entry)];
long long _aligner_1;
long double _aligner_2;
} storage;
static bool constructed = false;
if (!constructed)
{
new (storage.buffer) Entry();
constructed = true;
}
Entry* const entry = reinterpret_cast<Entry*>(storage.buffer);
{
const RegistResult remove_res = remove(entry);
const RegistResult remove_res = remove(&entry);
if (remove_res != RegistResultOk)
{
return remove_res;
}
}
new (storage.buffer) Entry(DataTypeKind(Type::DataTypeKind), id, Type::getDataTypeSignature(),
Type::getDataTypeFullName());
entry = Entry(DataTypeKind(Type::DataTypeKind), id, Type::getDataTypeSignature(), Type::getDataTypeFullName());
{
const RegistResult remove_res = remove(entry);
const RegistResult remove_res = remove(&entry);
if (remove_res != RegistResultOk)
{
return remove_res;
}
}
return registImpl(entry);
return registImpl(&entry);
}
}