I think Dan's logic is probably that it avoids calling get_wdf_upper_bound() twice in the (very common) case where it returns non-zero,

However, get_wdf_upper_bound() is just an inlined getter method in the Xapian::Weight base class, which returns a member variable from the base class, so in this case the compiler will be able to eliminate the second call.

But if we assign to wdfn_upper and then test, we're forcing a conversion to double which may have been unnecessary.  So I'd say the code is actually better left as it was.