[Debug] enhance perf of DebugClassLoader

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #10860
| License       | MIT
| Doc PR        | none

- restricts the check for case mismatch to Windows and Darwin,
- on Darwin, use glob() trick to bypass more extensive checks