LPS-47251

Hey Hugo,

Thanks for catching that NPE. I removed my changes to the if statement and left in the performance change so that we avoid the NPE but also sort of keep the changes from MHan.

Thanks.