I did the exact same horizontal casting ray for part 2. Where it is slow is because I used the map as if the symbols could be wrong. Like if you could see -|, and just the loop would be correct.
When I understood all the pipes are properly connected I refactored a bit but it was too late to change everything.
But now you make me want to fix it XD


















