I don't generally look at the code off-stream, so I'm just going by memory here:
My suspicion is that I realized that I wouldn't know which pointer to return in the case of a non-merge, so I couldn't have gone:
| Block = MergeIfPossible(Prior, Block);
Block = MergeIfPossible(Block, Next);
|
Which is what I actually wanted to write. I couldn't do this because
someone has to do the test, since MergeIfPossible needs to make sure it returns the free block in a non-merge case, which would require checking the flag explicitly and remember which one was free (maybe that can be slipstreamed into the work, I don't remember).
What I am realizing now that I have more time to think about it, is that you probably could be Mr. Sly Pants and do this instead:
| Block = MergeIfPossible(Prior, Block);
MergeIfPossible(Block, Next);
|
Now you just write MergeIfPossible to always return the second parameter if no merge happened, and the merged block if it did, and that "just works", right... so that's another thing I could have done. I think I probably like it the way it is now, though, because it's clearer what's going on in both functions, actually.
- Casey