perf(yarn3): eagerly construct map from workspace paths to locators (#6797)
### Description
When adding support for Yarn3's resolutions, we added a lookup to find
the workspace locator so we could check if there were any overrides.
The way this was implemented was lazily looking through the locators for
one which had the range of the form `workspace:path/to/workspace`. This
was a linear search that got performed for each workspace in the
repository e.g. O(n^2).
This PR changes to eagerly build up this map to provide a quick lookup.
This happens during our initial iteration of the packages in the
lockfile. We keep the old inefficient behavior as fallback just in case
it covered some cases that the new eager approach misses i.e. a
workspace with a locator of the form
`my-package@workspace:something^now/comes/the/path` (I do not think
locators like this are produced by Yarn, but this can give confidence
that we aren't breaking users with this change)
### Testing Instructions
👀
Traces from calculating all transitive closures in a repo with 1000
workspaces.
Main
[slow.trace.zip](https://github.com/vercel/turbo/files/13679445/slow.trace.zip)
With PR
[fast.trace.zip](https://github.com/vercel/turbo/files/13679447/fast.trace.zip)
Closes TURBO-1936