Skip to content

Commit

Permalink
DString reverse and an initial BigInt implementation (untested),
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Oct 1, 2024
1 parent 46ae435 commit 9b49d19
Show file tree
Hide file tree
Showing 5 changed files with 1,173 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/std/core/dstring.c3
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,19 @@ fn void! out_string_append_fn(void* data, char c) @private
s.append_char(c);
}

fn void DString.reverse(self)
{
StringData *data = self.data();
if (!data) return;
isz mid = data.len / 2;
for (isz i = 0; i < mid; i++)
{
char temp = data.chars[i];
isz reverse_index = data.len - 1 - i;
data.chars[i] = data.chars[reverse_index];
data.chars[reverse_index] = temp;
}
}

fn StringData* DString.data(self) @inline @private
{
Expand Down
Loading

0 comments on commit 9b49d19

Please sign in to comment.