Improved performance of Definition

1) Improved finding locked_deps efficiency in coverage_local_specs
   from O(N^2) to O(N).
2) Improved specs_changed from O(N^2) to O(N)
Use inject instead of each_with_object for 1.8.7 compability
Merge pull request #2983 from Who828/master

Improved performance of Definition