yaroslav / russian

Russian language support for Ruby and Rails | Поддержка русского языка для Ruby и Rails
MIT License
475 stars 127 forks source link

Performance optimization for transliteration #42

Closed ujifgc closed 10 years ago

ujifgc commented 11 years ago
  1. Freeze the regex so it's not created every time
  2. Move LOWER[char] to the top of the condition
  3. Minimize hash searches

Performance boost is 2-3 times on short strings and 20-30% on long ones.