Fix perfromance when there's lots of error
DiagnosticsCollection#Add() uses InsertSort, this causes a ton of memcopys on every error. This is O(n) for every error.
Instead I moved the sort to lazily happen just before each GetDiagnostics call this is O(nlogn), but gets happen way less often than Inserts.
This happens on codebases with lots of usages of react-hook-form due to https://github.com/microsoft/typescript-go/issues/988 . While this isn't a fix for that it allows builds to fail instead of hanging for hours
This looks fine, but you should run hereby format.
This turns out to be unsafe; it causes a data race when concurrently accessing processor diagnostics. We don't see the problem in main, though, only on a WIP branch I have for bringing back #2197.
And, since it sorts the list on the fly, if something previously grabbed a list of diags (say, the global diags), and then they changed later, the list would potentially be concurrently modified.