[Refactoring] Improve performance of searching for type definitions.