Use String#tr instead of String#gsub

String#tr is faster than String#gsub.