Skip to content

Commit

Permalink
Tried to adopt consistent flip/flop/follow indention in rbyd functions
Browse files Browse the repository at this point in the history
The intention here is to try to help readability by keeping arg
locations somewhat consistent.

Readability is already difficult enough given that these functions are
so context dependent...
  • Loading branch information
geky committed Apr 23, 2024
1 parent 8bfb1be commit 8849829
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,12 +957,14 @@ static inline void lfsr_tag_trim2(
lfsr_srid_t *lower_rid, lfsr_srid_t *upper_rid,
lfsr_tag_t *lower_tag, lfsr_tag_t *upper_tag) {
if (lfsr_tag_isred(alt2)) {
lfsr_tag_trim(alt2, weight2,
lfsr_tag_trim(
alt2, weight2,
lower_rid, upper_rid,
lower_tag, upper_tag);
}

lfsr_tag_trim(alt, weight,
lfsr_tag_trim(
alt, weight,
lower_rid, upper_rid,
lower_tag, upper_tag);
}
Expand Down Expand Up @@ -2456,12 +2458,23 @@ static int lfsr_rbyd_lookupnext(lfs_t *lfs, const lfsr_rbyd_t *rbyd,

// found an alt?
if (lfsr_tag_isalt(alt)) {
if (lfsr_tag_follow(alt, weight, lower_rid, upper_rid, rid, tag)) {
lfsr_tag_flip(&alt, &weight, lower_rid, upper_rid);
lfsr_tag_trim(alt, weight, &lower_rid, &upper_rid, NULL, NULL);
if (lfsr_tag_follow(
alt, weight,
lower_rid, upper_rid,
rid, tag)) {
lfsr_tag_flip(
&alt, &weight,
lower_rid, upper_rid);
lfsr_tag_trim(
alt, weight,
&lower_rid, &upper_rid,
NULL, NULL);
branch = branch - jump;
} else {
lfsr_tag_trim(alt, weight, &lower_rid, &upper_rid, NULL, NULL);
lfsr_tag_trim(
alt, weight,
&lower_rid, &upper_rid,
NULL, NULL);
branch = branch + d;
}

Expand Down Expand Up @@ -2906,7 +2919,8 @@ trunk:;
p[0].alt, p[0].weight,
lower_rid, upper_rid,
a_rid, a_tag)) {
lfsr_tag_flip2(&alt, &weight,
lfsr_tag_flip2(
&alt, &weight,
p[0].alt, p[0].weight,
lower_rid, upper_rid);
lfs_swap32(&jump, &branch_);
Expand All @@ -2919,7 +2933,8 @@ trunk:;
// | .-'| .--|-'|
// 1 2 3 1 2 3 1
if (lfsr_tag_isred(p[0].alt)
&& lfsr_tag_follow(p[0].alt, p[0].weight,
&& lfsr_tag_follow(
p[0].alt, p[0].weight,
lower_rid, upper_rid,
a_rid, a_tag)) {
lfs_swap16(&p[0].alt, &alt);
Expand All @@ -2928,7 +2943,8 @@ trunk:;
alt = (alt & ~LFSR_TAG_R) | (p[0].alt & LFSR_TAG_R);
p[0].alt |= LFSR_TAG_R;

lfsr_tag_flip2(&alt, &weight,
lfsr_tag_flip2(
&alt, &weight,
p[0].alt, p[0].weight,
lower_rid, upper_rid);
lfs_swap32(&jump, &branch_);
Expand Down Expand Up @@ -3155,7 +3171,8 @@ trunk:;
if (lfsr_tag_isred(alt)) {
// undo flip temporarily
if (branch_ < branch) {
lfsr_tag_flip2(&alt, &weight,
lfsr_tag_flip2(
&alt, &weight,
p[0].alt, p[0].weight,
lower_rid, upper_rid);
lfs_swap32(&jump, &branch_);
Expand Down

0 comments on commit 8849829

Please sign in to comment.