Micro-optimizations around string comparisons

Replacing some operations with faster, potentially more readable versions. Faster is relative here - this isn't going to make much impact overall, I don't think.