[Tux3] dleaf ordered check
Daniel Phillips
phillips at phunq.net
Wed Sep 3 01:39:13 PDT 2008
Hi Conrad,
Here's my little hack to check order. It is _maybe_ marginally more
readable than the original dleaf dump. I find it makes most sense to
have the dicts point at the zeroth entry for dleaf as opposed to ileaf
where pointing one higher seems to give the best code.
Do with as you will.
int dleaf_ordered(BTREE, struct dleaf *leaf)
{
struct group *gdict = (void *)leaf + btree->sb->blocksize;
struct entry *edict = (void *)(--gdict - leaf->groups);
unsigned groupbase = 0;
tuxkey_t lastkey = 0;
for (int group = 0; group > -leaf->groups; group--) {
tuxkey_t basekey = (tuxkey_t)gdict[group].loghi << 24;
unsigned offset = 0;
for (int entry = 0; entry > -gdict[group].count; entry--) {
unsigned limit = edict[entry].limit;
tuxkey_t key = basekey | edict[entry].loglo;
if (key < lastkey || limit < offset)
return 0;
offset = limit;
lastkey = key;
}
groupbase += offset;
edict -= gdict[group].count;
}
return 1;
}
_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3
More information about the Tux3
mailing list