Skip to content

Commit

Permalink
std::core::dstring: fix DString.zstr() (#1024)
Browse files Browse the repository at this point in the history
rename DString.zstr to DString.zstr_view
  • Loading branch information
pierrec authored Oct 2, 2023
1 parent 2b9276b commit 757a5b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/std/core/dstring.c3
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 757a5b5

Please sign in to comment.