Skip to content

Commit 8b44ecd

Browse files
committed
Update pointer_set::iterator to hold raw reference to container
Signed-off-by: yamacir-kit <[email protected]>
1 parent a79c9c4 commit 8b44ecd

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ $ sudo apt remove meevax
9797

9898
| Target Name | Description
9999
|--------------------|---
100-
| `all` (default) | Build shared-library `libmeevax.0.4.596.so` and executable `meevax`.
100+
| `all` (default) | Build shared-library `libmeevax.0.4.597.so` and executable `meevax`.
101101
| `test` | Test executable `meevax`.
102-
| `package` | Generate debian package `meevax_0.4.596_amd64.deb`.
102+
| `package` | Generate debian package `meevax_0.4.597_amd64.deb`.
103103
| `install` | Copy files into `/usr/local` __(1)__.
104104
| `install.deb` | `all` + `package` + `sudo apt install <meevax>.deb`
105105
| `safe-install.deb` | `all` + `test` + `package` + `sudo apt install <meevax>.deb`
@@ -114,7 +114,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's
114114
## Usage
115115

116116
```
117-
Meevax Lisp 0.4.596
117+
Meevax Lisp 0.4.597
118118
119119
Usage:
120120
meevax [option...] [file...]

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.596
1+
0.4.597

include/meevax/memory/pointer_set.hpp

+12-15
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ inline namespace memory
118118

119119
using difference_type = std::ptrdiff_t;
120120

121-
page const* pages;
122-
123-
std::size_t page_size;
121+
std::vector<page> const& pages;
124122

125123
std::size_t page_index;
126124

@@ -129,8 +127,7 @@ inline namespace memory
129127
explicit iterator(std::vector<page> const& pages,
130128
std::size_t page_index_hint,
131129
std::size_t word_index_hint) noexcept
132-
: pages { pages.data() }
133-
, page_size { pages.size() }
130+
: pages { pages }
134131
, page_index { page_index_hint }
135132
, word_index { word_index_hint }
136133
{
@@ -141,16 +138,14 @@ inline namespace memory
141138
}
142139

143140
explicit iterator(std::vector<page> const& pages) noexcept
144-
: pages { pages.data() }
145-
, page_size { pages.size() }
146-
, page_index { page_size }
141+
: pages { pages }
142+
, page_index { pages.size() }
147143
, word_index { word_size }
148144
{}
149145

150146
explicit operator bool() const noexcept
151147
{
152-
return page_index < page_size and
153-
word_index < word_size and pages[page_index][word_index];
148+
return page_index < pages.size() and word_index < word_size and pages[page_index][word_index];
154149
}
155150

156151
auto operator *() const noexcept
@@ -162,7 +157,7 @@ inline namespace memory
162157
{
163158
++word_index;
164159

165-
for (; page_index < page_size; ++page_index)
160+
for (; page_index < pages.size(); ++page_index)
166161
{
167162
for (auto&& word = pages[page_index]; word_index < word_size; ++word_index)
168163
{
@@ -175,7 +170,8 @@ inline namespace memory
175170
word_index = 0;
176171
}
177172

178-
page_index = page_size;
173+
page_index = pages.size();
174+
179175
word_index = word_size;
180176

181177
return *this; // end
@@ -190,8 +186,9 @@ inline namespace memory
190186

191187
auto operator --() noexcept -> auto &
192188
{
193-
page_index = page_size <= page_index ? page_size - 1 : page_index;
194-
word_index = word_size <= word_index ? word_size - 1 : word_index - 1;
189+
page_index = std::min(pages.size() - 1, page_index);
190+
191+
word_index = std::min(word_size - 1, word_index - 1);
195192

196193
/*
197194
NOTE: N4659 6.9.1.4
@@ -200,7 +197,7 @@ inline namespace memory
200197
n is the number of bits in the value representation of that
201198
particular size of integer.
202199
*/
203-
for (; page_index < page_size; --page_index)
200+
for (; page_index < pages.size(); --page_index)
204201
{
205202
for (auto&& word = pages[page_index]; word_index < word_size; --word_index)
206203
{

0 commit comments

Comments
 (0)