Skip to content

Commit

Permalink
Remove use of std::string
Browse files Browse the repository at this point in the history
This stack allocates and copies a c-string to replace the calls to std::string.
  • Loading branch information
mjp41 committed Sep 24, 2024
1 parent ca46677 commit d87b367
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/snmalloc/ds_core/redblacktree.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <array>
#include <cstddef>
#include <cstdint>
#include <string>

namespace snmalloc
{
Expand Down Expand Up @@ -439,9 +438,19 @@ namespace snmalloc
depth);
if (!(get_dir(true, curr).is_null() && get_dir(false, curr).is_null()))
{
auto s_indent = std::string(indent);
print(get_dir(true, curr), (s_indent + "|").c_str(), depth + 1);
print(get_dir(false, curr), (s_indent + " ").c_str(), depth + 1);
char s_indent[128];
size_t end=0;
for (; end < 127; end++)
{
if (indent[end] == 0)
break;
s_indent[end] = indent[end];
}
s_indent[end] = '|';
s_indent[end + 1] = 0;
print(get_dir(true, curr), s_indent, depth + 1);
s_indent[end] = ' ';
print(get_dir(false, curr), s_indent, depth + 1);
}
}
}
Expand Down

0 comments on commit d87b367

Please sign in to comment.