std::core::dstring: fix DString.zstr() (#1024)

rename DString.zstr to DString.zstr_view
This commit is contained in:
Pierre Curto
2023-10-03 00:32:56 +02:00
committed by GitHub
parent 2b9276b495
commit 757a5b58e8

View File

@@ -56,13 +56,14 @@ fn DString DString.new_concat(self, DString b, Allocator* using = mem::heap())
fn DString DString.new_tconcat(self, DString b) => self.new_concat(b, mem::temp());
fn ZString DString.zstr(self)
fn ZString DString.zstr_view(&self)
{
StringData* data = self.data();
if (!data) return "";
if (data.capacity == data.len)
{
self.reserve(1);
data = self.data();
data.chars[data.len] = 0;
}
else if (data.chars[data.len] != 0)
@@ -284,7 +285,7 @@ fn void DString.append_char(&self, char c)
*self = new_with_capacity(MIN_CAPACITY);
}
self.reserve(1);
StringData* data = (StringData*)*self;
StringData* data = self.data();
data.chars[data.len++] = c;
}