Added LFSR_BTREE/SHRUB_NULL, dropped lfsr_btree_alloc
Our B-trees lazily allocate their root blocks, so it makes more sense
for this to be a macro. Added/adopted a similar LFSR_SHRUB_NULL for
consistency.
Unfortunately this added a bit of code. I think because GCC struggles to
optimize compound literals, which both LFSR_BTREE_NULL and
LFSR_SHRUB_NULL expand into:
code stack
before: 33538 2624
after: 33550 (+0.0%) 2624 (+0.0%)
This commit is contained in:
@@ -3900,8 +3900,9 @@ static lfs_scmp_t lfsr_rbyd_namelookup(lfs_t *lfs, const lfsr_rbyd_t *rbyd,
|
||||
|
||||
/// B-tree operations ///
|
||||
|
||||
// convenience operations
|
||||
#define LFSR_BTREE_NULL() ((lfsr_btree_t){.weight=0, .trunk=0})
|
||||
|
||||
// convenience operations
|
||||
static inline int lfsr_btree_cmp(
|
||||
const lfsr_btree_t *a,
|
||||
const lfsr_btree_t *b) {
|
||||
@@ -4036,14 +4037,6 @@ static int lfsr_data_readbtree(lfs_t *lfs, lfsr_data_t *data,
|
||||
|
||||
// core btree operations
|
||||
|
||||
static int lfsr_btree_alloc(lfs_t *lfs, lfsr_btree_t *btree) {
|
||||
(void)lfs;
|
||||
// TODO do we need this function then?
|
||||
// allocate lazily
|
||||
*btree = (lfsr_btree_t){.trunk=0, .weight=0};
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lfsr_btree_lookupnext_(lfs_t *lfs, const lfsr_btree_t *btree,
|
||||
lfsr_bid_t bid,
|
||||
lfsr_bid_t *bid_, lfsr_rbyd_t *rbyd_, lfsr_srid_t *rid_,
|
||||
@@ -5204,6 +5197,14 @@ static int lfsr_sprout_compact(lfs_t *lfs, const lfsr_rbyd_t *rbyd_,
|
||||
|
||||
// shrub things
|
||||
|
||||
#define LFSR_SHRUB_NULL(_block) \
|
||||
((lfsr_shrub_t){ \
|
||||
.weight=0, \
|
||||
.blocks[0]=_block, \
|
||||
.trunk=LFSR_RBYD_ISSHRUB | 0, \
|
||||
/* force estimate recalculation */ \
|
||||
.estimate=-1})
|
||||
|
||||
// helper functions
|
||||
static inline bool lfsr_shrub_isshrub(const lfsr_shrub_t *shrub) {
|
||||
return lfsr_rbyd_isshrub((const lfsr_rbyd_t*)shrub);
|
||||
@@ -6886,10 +6887,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
|
||||
|
||||
// new mtree?
|
||||
if (lfsr_mtree_ismptr(&lfs->mtree)) {
|
||||
err = lfsr_btree_alloc(lfs, &mtree_.u.btree);
|
||||
if (err) {
|
||||
goto failed;
|
||||
}
|
||||
mtree_.u.btree = LFSR_BTREE_NULL();
|
||||
|
||||
uint8_t mdir_buf[2*LFSR_MPTR_DSIZE];
|
||||
err = lfsr_btree_commit(lfs, &mtree_.u.btree,
|
||||
@@ -10553,11 +10551,7 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file,
|
||||
LFSR_DATA_BPTR_(&file->bshrub.u.bptr, left.buf));
|
||||
}
|
||||
|
||||
file->bshrub.u.bshrub.blocks[0] = file->o.mdir.rbyd.blocks[0];
|
||||
file->bshrub.u.bshrub.trunk = LFSR_RBYD_ISSHRUB | 0;
|
||||
file->bshrub.u.bshrub.weight = 0;
|
||||
// force estimate recalculation
|
||||
file->bshrub.u.bshrub.estimate = -1;
|
||||
file->bshrub.u.bshrub = LFSR_SHRUB_NULL(file->o.mdir.rbyd.blocks[0]);
|
||||
|
||||
if (attr_count > 0) {
|
||||
LFS_ASSERT(attr_count <= sizeof(attrs)/sizeof(lfsr_attr_t));
|
||||
|
||||
@@ -42,8 +42,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// set up a simulation to compare against
|
||||
char *sim = malloc(N);
|
||||
@@ -150,8 +149,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// set up a simulation to compare against
|
||||
char *sim = malloc(N);
|
||||
@@ -254,8 +252,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// set up a simulation to compare against
|
||||
char *sim = malloc(N);
|
||||
|
||||
+50
-100
@@ -20,8 +20,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create an empty tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
printf("btree: w%d 0x%x.%x\n",
|
||||
btree.weight,
|
||||
btree.blocks[0],
|
||||
@@ -52,8 +51,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a single-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
printf("btree: w%d 0x%x.%x\n",
|
||||
@@ -94,8 +92,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a two-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
lfsr_btree_commit(&lfs, &btree, 1, LFSR_ATTRS(
|
||||
@@ -144,8 +141,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a two-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("b", 1)))) => 0;
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
@@ -195,8 +191,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a two-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
lfsr_btree_commit(&lfs, &btree, 1, LFSR_ATTRS(
|
||||
@@ -254,8 +249,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a two-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("c", 1)))) => 0;
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
@@ -316,8 +310,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfs_size_t n = 0;
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i, LFSR_ATTRS(
|
||||
@@ -367,8 +360,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfs_size_t n = 0;
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
@@ -419,8 +411,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// set up a simulation to compare against
|
||||
//
|
||||
@@ -502,8 +493,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfs_size_t n = 0;
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i*W, LFSR_ATTRS(
|
||||
@@ -570,8 +560,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// set up a simulation to compare against
|
||||
//
|
||||
@@ -706,8 +695,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a single-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
// update the tree
|
||||
@@ -752,8 +740,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a two-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
lfsr_btree_commit(&lfs, &btree, 1, LFSR_ATTRS(
|
||||
@@ -811,8 +798,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a two-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
lfsr_btree_commit(&lfs, &btree, 1, LFSR_ATTRS(
|
||||
@@ -884,8 +870,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
@@ -941,8 +926,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
@@ -1028,8 +1012,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i*W, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
@@ -1101,8 +1084,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i*W, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
@@ -1245,8 +1227,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a single-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
// pop!
|
||||
@@ -1302,8 +1283,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a single-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
lfsr_btree_commit(&lfs, &btree, 1, LFSR_ATTRS(
|
||||
@@ -1375,8 +1355,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a single-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
lfsr_btree_commit(&lfs, &btree, 1, LFSR_ATTRS(
|
||||
@@ -1448,8 +1427,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a single-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("a", 1)))) => 0;
|
||||
lfsr_btree_commit(&lfs, &btree, 1, LFSR_ATTRS(
|
||||
@@ -1540,8 +1518,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
@@ -1620,8 +1597,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
@@ -1702,8 +1678,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
@@ -1791,8 +1766,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i*W, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
@@ -1897,8 +1871,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// set up a simulation to compare against
|
||||
//
|
||||
@@ -2048,8 +2021,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
LFSR_TAG_DATA, +1,
|
||||
@@ -2107,8 +2079,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +1, LFSR_DATA_BUF("_", 1)))) => 0;
|
||||
|
||||
@@ -2197,8 +2168,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(
|
||||
LFSR_TAG_DATA, +W,
|
||||
@@ -2257,8 +2227,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR(LFSR_TAG_DATA, +W, LFSR_DATA_BUF("_", 1)))) => 0;
|
||||
|
||||
@@ -2434,8 +2403,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// force it to split
|
||||
|
||||
@@ -2502,8 +2470,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// force it to split
|
||||
|
||||
@@ -2573,8 +2540,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// force it to split
|
||||
|
||||
@@ -2637,8 +2603,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// force it to split
|
||||
|
||||
@@ -2717,8 +2682,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// set up a simulation to compare against
|
||||
//
|
||||
@@ -2823,8 +2787,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// set up a simulation to compare against
|
||||
//
|
||||
@@ -2990,8 +2953,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a zero-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
printf("btree: w%d 0x%x.%x\n",
|
||||
btree.weight,
|
||||
btree.blocks[0],
|
||||
@@ -3024,8 +2986,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a single-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR_NAME(
|
||||
LFSR_TAG_NAME, +1,
|
||||
@@ -3077,8 +3038,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a two-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR_NAME(
|
||||
LFSR_TAG_NAME, +1,
|
||||
@@ -3144,8 +3104,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a two-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR_NAME(
|
||||
LFSR_TAG_NAME, +1,
|
||||
@@ -3225,8 +3184,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a two-entry tree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR_NAME(
|
||||
LFSR_TAG_NAME, +1,
|
||||
@@ -3307,8 +3265,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
char name[3] = {
|
||||
'a'+((0/26/26) % 26), 'a'+((0/26) % 26), 'a'+(0 % 26)
|
||||
};
|
||||
@@ -3380,8 +3337,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR_NAME(
|
||||
LFSR_TAG_NAME, +1,
|
||||
@@ -3495,8 +3451,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
char name[3] = {
|
||||
'a'+((0/26/26) % 26), 'a'+((0/26) % 26), 'a'+(0 % 26)
|
||||
};
|
||||
@@ -3569,8 +3524,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR_NAME(
|
||||
LFSR_TAG_NAME, +W,
|
||||
@@ -3725,8 +3679,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR_NAME(
|
||||
LFSR_TAG_NAME, +1,
|
||||
@@ -3882,8 +3835,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfsr_btree_commit(&lfs, &btree, 0, LFSR_ATTRS(
|
||||
LFSR_ATTR_NAME(
|
||||
LFSR_TAG_NAME, +W,
|
||||
@@ -4088,8 +4040,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a tree with N elements
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
lfs_size_t n = 0;
|
||||
for (lfs_size_t i = 0; i < N; i++) {
|
||||
lfsr_btree_commit(&lfs, &btree, i, LFSR_ATTRS(
|
||||
@@ -4210,8 +4161,7 @@ code = '''
|
||||
lfs_alloc_ckpoint(&lfs);
|
||||
|
||||
// create a btree
|
||||
lfsr_btree_t btree;
|
||||
lfsr_btree_alloc(&lfs, &btree) => 0;
|
||||
lfsr_btree_t btree = LFSR_BTREE_NULL();
|
||||
|
||||
// set up a simulation to compare against
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user