Update: I'm going to leave it as it is: Declining exception performance (very rare) is better than probably performance for checking each operation (overall)
I am trying to support "EstimatedRowCount", which in one case will be the product of two sub-cursors that are connected together:
estimatedRowCount = left.EstimatedRowCount * right.EstimatedRowCount; return estimatedRowCount;
Of course, if the left and right are large enough, this will throw an OverflowException.
Here, I donโt care if the estimated RowCount is 100% accurate, large enough to know that this cursor contains a lot of data.
Now I am doing this:
// We multiply our rowcount Int64 estimRowCount = 0; try { estimRowCount = leftRowCount * rightRowCount; } catch (OverflowException) { // Ignore overflow exceptions estimRowCount = Int64.MaxValue; } return estimRowCount;
Is there a better way to check overflow operations, so I donโt need to do try {} catch for protection?
source share