In most cases when a slime does a spawn attempt it recalculates if the chunk it tries to spawn in is a slime chunk
As you can see in the code, the came checks if the spawn attempt is in a swamp between y50 and y70 first (along with some other stuff). If that is not the case the spawn attempt will always calculate if it's in a slime chunk or not. This is a very inefficient way of handling this.
One better way of doing it would be to either calculate if a chunk is a slime chunk when the world generates and using that each spawn attempt, or at least moving some of the if statements around so it doesn't calculate if its a slime chunk even if the spawn attempt happens at y200 where obviously no slime should ever be able to spawn if it's not in a swamp.
Doing this seems like a waste of resources since it would be very easy to optimize it.