The Inside() method for boolean solids G4UnionSolid, G4SubtractionSolid, and G4IntersectionSolid can be sped up if a short circuit test is applied after testing solid A, but before testing solid B. For example, in a subtraction solid, you can do: EInside G4SubtractionSolid::Inside( const G4ThreeVector& p ) const { EInside positionA = fPtrSolidA->Inside(p); + + if (positionA == kOutside) + return kOutside; + EInside positionB = fPtrSolidB->Inside(p); This avoids calling Inside() on solid B unless necessary. Similarly, one can do the same thing to G4UnionSolid: EInside G4UnionSolid::Inside( const G4ThreeVector& p ) const { EInside positionA = fPtrSolidA->Inside(p); + + if (positionA == kInside) + return kInside; + EInside positionB = fPtrSolidB->Inside(p); A similar patch could be made to G4IntersectionSolid, though I haven't tried it yet. These changes improve the performance of complex boolean solid geometries quite a bit.
These modifications were introduced in subtracted and union solids, while it already existed in intersection.