do binary lookup for switches
Merge pull request #2320 from WalterBright/binary-switch

do binary lookup for switches