Use @evilstreak's implementation of match_locations.

Benchmarks show this runs the fastest and takes the least memory.