Closed SethPyle376 closed 1 year ago
Ah, this is a tricky one! The first one, in line 254, is necessary since the case statement above it doesn't always break
at the end; it may fall through, and when it does, it will have modified mid
, so it needs to be re-set.
You are correct about the second one being redundant, but that's an artifact of pbrt's literate program heritage; the code there is reusing the "Partition primitives into equally sized subsets" fragment. So in return for making the book slightly shorter through reusing that fragment, we get a redundancy in the C++ code. I prefer to leave this as is, just to keep the code in sync with the book.
Keep 'em coming if you see anything else fishy though!
Ah I see, thanks for the explanation!
Mid is pre-calculated to the same value here for a couple of these split methods :)