xo-expression2: + DUniqueString, use in StringTable
This commit is contained in:
parent
a51af1bad2
commit
6f8fb9f15a
9 changed files with 304 additions and 26 deletions
|
|
@ -58,16 +58,24 @@ namespace xo {
|
|||
}
|
||||
|
||||
DString *
|
||||
DString::from_view(obj<AAllocator> mm,
|
||||
std::string_view sv)
|
||||
DString::_from_view_aux(obj<AAllocator> mm,
|
||||
std::string_view sv,
|
||||
bool suballoc_flag)
|
||||
{
|
||||
size_type len = sv.size();
|
||||
size_type cap = len + 1;
|
||||
|
||||
void * mem = mm.alloc(typeseq::id<DString>(),
|
||||
sizeof(DString) + cap);
|
||||
auto tseq = typeseq::id<DString>();
|
||||
void * mem = nullptr;
|
||||
size_type mem_z = sizeof(DString) + cap;
|
||||
|
||||
if (suballoc_flag)
|
||||
mem = mm.sub_alloc(mem_z, false /*!complete_flag*/);
|
||||
else
|
||||
mem = mm.alloc(tseq, mem_z);
|
||||
|
||||
DString * result = new (mem) DString();
|
||||
|
||||
result->capacity_ = cap;
|
||||
result->size_ = len;
|
||||
std::memcpy(result->chars_, sv.data(), len);
|
||||
|
|
@ -76,6 +84,20 @@ namespace xo {
|
|||
return result;
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::from_view(obj<AAllocator> mm,
|
||||
std::string_view sv)
|
||||
{
|
||||
return _from_view_aux(mm, sv, false /*!suballoc_flag*/);
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::from_view_suballoc(obj<AAllocator> mm,
|
||||
std::string_view sv)
|
||||
{
|
||||
return _from_view_aux(mm, sv, true /*suballoc_flag*/);
|
||||
}
|
||||
|
||||
DString *
|
||||
DString::clone(obj<AAllocator> mm, const DString * src)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue