Skip to content

Commit

Permalink
api: fix rune handling of strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 3, 2024
1 parent 102e6d8 commit bdc56c7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/str.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace jule
static jule::Str from_rune(const jule::I32 r) noexcept
{
jule::Str s;
s._len = 0;
s.buffer = jule::Str::buffer_t::make(jule::Str::alloc(4));
s._slice = s.buffer.alloc;
jule::utf8_push_rune_bytes(r, s);
Expand Down Expand Up @@ -99,8 +100,8 @@ namespace jule

Str(const jule::Slice<jule::I32> &src)
{
this->_len = src.len() << 2;
this->buffer = jule::Str::buffer_t::make(jule::Str::alloc(this->_len));
this->_len = 0;
this->buffer = jule::Str::buffer_t::make(jule::Str::alloc(src.len() << 2));
this->_slice = this->buffer.alloc;
for (const jule::I32 &r : src)
jule::utf8_push_rune_bytes(r, *this);
Expand Down

0 comments on commit bdc56c7

Please sign in to comment.