Skip to content

Commit

Permalink
Remove some unneeded headers (#680)
Browse files Browse the repository at this point in the history
* Removed unneeded headers

This removes some unneeded headers from the headers.

* Remove use of std::string

This stack allocates and copies a c-string to replace the calls to std::string.
  • Loading branch information
mjp41 authored Oct 6, 2024
1 parent c770769 commit 97b7675
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/snmalloc/backend_helpers/largebuddyrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "empty_range.h"
#include "range_helpers.h"

#include <string>

namespace snmalloc
{
/**
Expand Down
1 change: 0 additions & 1 deletion src/snmalloc/ds/combininglock.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "../pal/pal.h"

#include <atomic>
#include <functional>

namespace snmalloc
{
Expand Down
1 change: 0 additions & 1 deletion src/snmalloc/ds/flaglock.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "../pal/pal.h"

#include <atomic>
#include <functional>

namespace snmalloc
{
Expand Down
2 changes: 0 additions & 2 deletions src/snmalloc/ds/singleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include "../ds_core/ds_core.h"
#include "flaglock.h"

#include <array>
#include <atomic>
#include <string_view>
#include <type_traits>

namespace snmalloc
Expand Down
2 changes: 1 addition & 1 deletion src/snmalloc/ds_core/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include <array>
#include <atomic>
#include <functional>
#include <string_view>
#include <tuple>
#include <type_traits>

namespace snmalloc
Expand Down
25 changes: 21 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,27 @@ 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);
// As the tree should be balanced, the depth should not exceed 128 if
// there are 2^64 elements in the tree. This is a debug feature, and
// it would be impossible to debug something of this size, so this is
// considerably larger than required.
// If there is a bug that leads to an unbalanced tree, this might be
// insufficient to accurately display the tree, but it will still be
// memory safe as the search code is bounded by the string size.
static constexpr size_t max_depth = 128;
char s_indent[max_depth];
size_t end = 0;
for (; end < max_depth - 1; 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
1 change: 0 additions & 1 deletion src/snmalloc/mem/freelist_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "../ds/ds.h"
#include "freelist.h"

#include <array>
#include <atomic>

namespace snmalloc
Expand Down
2 changes: 2 additions & 0 deletions src/snmalloc/mem/remoteallocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "freelist_queue.h"

#include <new>

namespace snmalloc
{
class RemoteMessageAssertions;
Expand Down
1 change: 0 additions & 1 deletion src/snmalloc/pal/pal_consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "../ds_core/ds_core.h"

#include <atomic>
#include <functional>

namespace snmalloc
{
Expand Down
1 change: 0 additions & 1 deletion src/snmalloc/pal/pal_ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "../ds_core/ds_core.h"

#include <atomic>
#include <functional>

namespace snmalloc
{
Expand Down
1 change: 0 additions & 1 deletion src/test/func/redblack/redblack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "test/xoroshiro.h"

#include <algorithm>
#include <array>
#include <iostream>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions src/test/perf/startup/startup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "test/usage.h"
#include "test/xoroshiro.h"

#include <algorithm>
#include <iostream>
#include <snmalloc/snmalloc.h>
#include <thread>
Expand Down

0 comments on commit 97b7675

Please sign in to comment.