BAN: String now uses union for its sso storage
This allows String to shrink by 8 bytes since Variant's 8 index is no longer stored in here. This required me to make Strings max size one bit less, but that should still be fine. There should never be strings with size of over half of the computer's address space.
This commit is contained in:
@@ -82,17 +82,21 @@ namespace BAN
|
||||
private:
|
||||
struct SSOStorage
|
||||
{
|
||||
char storage[sso_capacity + 1] {};
|
||||
char data[sso_capacity + 1] {};
|
||||
};
|
||||
struct GeneralStorage
|
||||
{
|
||||
size_type capacity { 0 };
|
||||
char* data;
|
||||
size_type capacity { 0 };
|
||||
char* data { nullptr };
|
||||
};
|
||||
|
||||
private:
|
||||
Variant<SSOStorage, GeneralStorage> m_storage { SSOStorage() };
|
||||
size_type m_size { 0 };
|
||||
union {
|
||||
SSOStorage sso_storage;
|
||||
GeneralStorage general_storage;
|
||||
} m_storage { .sso_storage = SSOStorage() };
|
||||
size_type m_size : sizeof(size_type) * 8 - 1 { 0 };
|
||||
size_type m_has_sso : 1 { true };
|
||||
};
|
||||
|
||||
template<typename... Args>
|
||||
|
||||
Reference in New Issue
Block a user