Skip to content

Commit

Permalink
Cleanup struct integer_set
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Nov 3, 2024
1 parent 37d80e2 commit c53aceb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.5.257_amd64.deb
sudo apt install build/meevax_0.5.258_amd64.deb
```

or
Expand Down Expand Up @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.257.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.258.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.257_amd64.deb`
| `package` | Generate debian package `meevax_0.5.258_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.257
0.5.258
2 changes: 1 addition & 1 deletion include/meevax/memory/collector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ inline namespace memory
0x0000'0000'0000'0000 ~ 0x7FFF'FFFF'FFFF'FFFF
*/
template <typename T>
using pointer_set = integer_set<T const*, 15, 16, 16>;
using pointer_set = integer_set<T const*, log2(0x7FFF), log2(0xFFFF), log2(0xFFFF)>;

private:
static inline pointer_set<top> objects {};
Expand Down
53 changes: 22 additions & 31 deletions include/meevax/memory/integer_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,14 @@ inline namespace memory

constexpr const_iterator() = default;

explicit const_iterator(integer_set const* container, std::size_t i) noexcept
: data { container->data }
, max { container->max }
, i { i }
{
assert(i <= N);
increment_unless_truthy();
}

template <typename... Ts>
explicit const_iterator(integer_set const* container, std::size_t i, std::size_t j, Ts&&... xs) noexcept
explicit const_iterator(integer_set const* container, std::size_t i, Ts&&... xs) noexcept
: data { container->data }
, max { container->max }
, i { i }
{
assert(i <= N);
increment_unless_truthy(j, std::forward<decltype(xs)>(xs)...);
increment_unless_truthy(std::forward<decltype(xs)>(xs)...);
}

explicit const_iterator(integer_set const* container) noexcept
Expand All @@ -103,35 +94,35 @@ inline namespace memory
assert(iter.data);
}

auto increment_unless_truthy() noexcept -> void
template <typename... Ts>
auto increment_unless_truthy(Ts&&... xs) noexcept -> void
{
assert(data);

if (good())
if constexpr (0 < sizeof...(Ts))
{
for (; i <= max; ++i)
if (not good() or not data[i] or not (iter = data[i]->lower_bound(std::forward<decltype(xs)>(xs)...)).good())
{
if (data[i] and (iter = data[i]->lower_bound(0)).good())
{
return;
}
++i;
increment_unless_truthy();
}

i = N;
}
else
{
if (good())
{
for (; i <= max; ++i)
{
if (data[i] and (iter = data[i]->lower_bound(0)).good())
{
return;
}
}

iter = {};
}

template <typename... Ts>
auto increment_unless_truthy(std::size_t j, Ts&&... xs) noexcept -> void
{
assert(data);
i = N;
}

if (not good() or not data[i] or not (iter = data[i]->lower_bound(j, std::forward<decltype(xs)>(xs)...)).good())
{
++i;
increment_unless_truthy();
iter = {};
}
}

Expand Down

0 comments on commit c53aceb

Please sign in to comment.