Hacker News new | ask | show | jobs
by rdlowrey 4541 days ago
The problem with this is you can accomplish essentially the same thing in userland if you know how to write a good "compiled regex" ... Calling the pcre functions in C land gains you very little. An extension is totally unnecessary.
1 comments

I don't think so.

Using pure PHP, you need to load a lot of class files. and function calls, method calls, hash find are pretty slow in pure PHP.

- First of all, while using C extension, you don't need to reload these php class files again and again. it reduces the class loading overhead.

- Seconds, looping and string comparison is pretty fast in C. it's because in pure PHP, it duplicates the string when calling functions/methods in the runtime.

- Third, there are a lot of spaces to optimize the code in C rather than in pure php.

- Last, pure PHP consumes a lot of memory, but in C extension, the memory footprint is pretty small.