This function is hot in the Port.reference_files case on platforms like Big Sur with WebKit2, as we're calling it with a long baseline search path and with many suffixes. A lot of the cost is in the repeated calls of os.path.join which notably only differ by the suffix.
Created attachment 427176 [details] Patch
Committed r276669 (237088@main): <https://commits.webkit.org/237088@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 427176 [details].
<rdar://problem/77232724>