Skip to content

Commit

Permalink
ufs_trunc_branch(): massage towards killing recursion
Browse files Browse the repository at this point in the history
We always have 0 < depth2 <= depth in there, so
if (--depth) {
	if (--depth2)
		A
	B
} else {
	C // not using depth2
}
D // not using depth2

is equivalent to

if (--depth2)
	A with s/depth/depth - 1/
if (--depth)
	B
else
	C
D

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jul 6, 2015
1 parent 6d1ebbc commit 6aab6dd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fs/ufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,12 +1145,12 @@ static void ufs_trunc_branch(struct inode *inode, unsigned *offsets, int depth2,
return;
}

if (--depth2) {
void *ind = ubh_get_data_ptr(uspi, ubh, from++);
ufs_trunc_branch(inode, offsets, depth2, depth - 1, ind);
ubh_mark_buffer_dirty(ubh);
}
if (--depth) {
if (--depth2) {
void *ind = ubh_get_data_ptr(uspi, ubh, from++);
ufs_trunc_branch(inode, offsets, depth2, depth, ind);
ubh_mark_buffer_dirty(ubh);
}
for (i = from ; i < uspi->s_apb ; i++) {
void *ind = ubh_get_data_ptr(uspi, ubh, i);
free_full_branch(inode, depth, ind);
Expand Down

0 comments on commit 6aab6dd

Please sign in to comment.