Optimize checking of compiler flags