Add null check to avoid subsequent locking and map operations

Comment From: rstoyanchev

Thanks for the pull request. I've handled this slightly differently by caching the no match.