language: Optimize language_for_file (#28671)

While working on #28670 this function showed up in my profiles; this PR
makes it evaluate some of it's conditions lazily + prevent constant
rebuilding of globset::Candidates.

Release Notes:

- N/A *or* Added/Fixed/Improved ...
98891e4c70Piotr Osiewicz committed on 4/14/2025, 11:18:45 AM· committed by GitHubparent5e57f14
2 files changedLine totals unavailable