EllisLab/CodeIgniter — Issue #929: convert_accented_characters is slow (text helper)
Author: svezina
Created: 2012-01-16 06:23:45+00:00
State: open

Hi all,

I'm working on a project with a function that uses convert_accented_characters intensively (5000-10000 times), and I've noticed things got quite slow.

I did benchmarks with a simple string "éîûè" being passed 1000 times in the function, and it took 1.1571 sec.

My personal solution was to change 2 things:

1) Using strtr() instead of preg_replace. (Brought time down to 1.0152 secs)
2) Putting the foreign characters array directly in the helper instead of including foreign_chars.php. (Brought time down to 0.0943 secs)

Overall, this makes the function 12 times faster. Now I know that this is an ugly change since it means having config elements in the helper, and making the characters array be 200 lines long instead of 50.. but the speed gain is convenient.

Anyway, I'm using my own helper function for now to speed it up, but do you think this would make it's way in the core? If so, let me know I'll take the opportunity to learn git and send the request.

SImon