use tr instead of gsub when possible

tr is over 5x faster than gsub, in this 2 cases they are interchangeable