cleanup
This commit is contained in:
parent
b37d390e12
commit
ee695b7243
2 changed files with 24 additions and 16 deletions
|
@ -800,8 +800,8 @@ main()
|
||||||
// every so often, either ...
|
// every so often, either ...
|
||||||
if (iterations % 1000 == 0) {
|
if (iterations % 1000 == 0) {
|
||||||
larger_please:;
|
larger_please:;
|
||||||
const int COUNT = 1024;
|
size_t COUNT = xorshift32() % 1024 + 513;
|
||||||
// ... add COUNT 4KiB pages, or
|
// ... add some amount of 4KiB pages, or
|
||||||
size_t len = COUNT;
|
size_t len = COUNT;
|
||||||
// The largest page is at list[1] because this is a reverse sorted list.
|
// The largest page is at list[1] because this is a reverse sorted list.
|
||||||
pgno_t pg = list[0] ? list[1] + 1 : 0;
|
pgno_t pg = list[0] ? list[1] + 1 : 0;
|
||||||
|
@ -843,7 +843,7 @@ main()
|
||||||
if (list[-1] > INITIAL_AMOUNT) {
|
if (list[-1] > INITIAL_AMOUNT) {
|
||||||
// ... a fraction of the time, remove COUNT / 2 of 4KiB pages.
|
// ... a fraction of the time, remove COUNT / 2 of 4KiB pages.
|
||||||
pgno_t pg;
|
pgno_t pg;
|
||||||
for (int i = 0; i < COUNT; i++) {
|
for (size_t i = 0; i < COUNT; i++) {
|
||||||
pg = list[list[0] - i];
|
pg = list[list[0] - i];
|
||||||
assert(sparsemap_is_set(map, pg) == true);
|
assert(sparsemap_is_set(map, pg) == true);
|
||||||
assert(_sparsemap_set(&map, pg, false) == pg);
|
assert(_sparsemap_set(&map, pg, false) == pg);
|
||||||
|
|
|
@ -423,7 +423,24 @@ __sm_chunk_map_set(__sm_chunk_t *map, size_t idx, bool value, size_t *pos, sm_bi
|
||||||
return SM_OK;
|
return SM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Finds the index of the \b n'th bit after \b offset bits with \b value.
|
/** @brief Merges into the chunk at \b offset all set bits from \b src.
|
||||||
|
*
|
||||||
|
* @param[in] map The chunk in question.
|
||||||
|
* @param[in] offset The fully aligned offset of the chunk to be merged.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
__sm_chunk_map_merge(sparsemap_t *map, sparsemap_idx_t offset, __sm_chunk_t src)
|
||||||
|
{
|
||||||
|
size_t capacity = __sm_chunk_map_get_capacity(&src);
|
||||||
|
for (sparsemap_idx_t j = 0; j < capacity; j++, offset++) {
|
||||||
|
if (__sm_chunk_map_is_set(&src, j)) {
|
||||||
|
sparsemap_set(map, offset, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Finds the index of the \b n'th bit after \b offset bits with \b
|
||||||
|
* value.
|
||||||
*
|
*
|
||||||
* Scans the chunk \b map until after \b offset bits (of any value) have
|
* Scans the chunk \b map until after \b offset bits (of any value) have
|
||||||
* passed and then begins counting the bits that match \b value looking
|
* passed and then begins counting the bits that match \b value looking
|
||||||
|
@ -797,6 +814,7 @@ __sm_get_size_impl(sparsemap_t *map)
|
||||||
return SM_SIZEOF_OVERHEAD + p - start;
|
return SM_SIZEOF_OVERHEAD + p - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/** @brief Aligns to SM_BITS_PER_VECTOR a given index \b idx.
|
/** @brief Aligns to SM_BITS_PER_VECTOR a given index \b idx.
|
||||||
*
|
*
|
||||||
* @param[in] idx The index to align.
|
* @param[in] idx The index to align.
|
||||||
|
@ -808,6 +826,7 @@ __sm_get_aligned_offset(size_t idx)
|
||||||
const size_t capacity = SM_BITS_PER_VECTOR;
|
const size_t capacity = SM_BITS_PER_VECTOR;
|
||||||
return (idx / capacity) * capacity;
|
return (idx / capacity) * capacity;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** @brief Aligns to SM_CHUNK_MAP_CAPACITY a given index \b idx.
|
/** @brief Aligns to SM_CHUNK_MAP_CAPACITY a given index \b idx.
|
||||||
*
|
*
|
||||||
|
@ -1082,7 +1101,7 @@ sparsemap_set(sparsemap_t *map, sparsemap_idx_t idx, bool value)
|
||||||
__sm_append_data(map, &buf[0], sizeof(buf));
|
__sm_append_data(map, &buf[0], sizeof(buf));
|
||||||
|
|
||||||
uint8_t *p = __sm_get_chunk_map_data(map, 0);
|
uint8_t *p = __sm_get_chunk_map_data(map, 0);
|
||||||
*(sm_idx_t *)p = __sm_get_fully_aligned_offset(idx); //TODO was not fully aligned before... why?
|
*(sm_idx_t *)p = __sm_get_fully_aligned_offset(idx); // TODO was not fully aligned before... why?
|
||||||
|
|
||||||
__sm_set_chunk_map_count(map, 1);
|
__sm_set_chunk_map_count(map, 1);
|
||||||
|
|
||||||
|
@ -1242,17 +1261,6 @@ sparsemap_scan(sparsemap_t *map, void (*scanner)(sm_idx_t[], size_t), size_t ski
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
__sm_chunk_map_merge(sparsemap_t *map, sparsemap_idx_t offset, __sm_chunk_t src)
|
|
||||||
{
|
|
||||||
size_t capacity = __sm_chunk_map_get_capacity(&src);
|
|
||||||
for (sparsemap_idx_t j = 0; j < capacity; j++, offset++) {
|
|
||||||
if (__sm_chunk_map_is_set(&src, j)) {
|
|
||||||
sparsemap_set(map, offset, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sparsemap_merge(sparsemap_t *map, sparsemap_t *other)
|
sparsemap_merge(sparsemap_t *map, sparsemap_t *other)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue