speed up based on gprof data
Merge pull request #2247 from WalterBright/speed_up_search

speed up based on gprof data