>
> but how can i pass the object from a private method of the PHP extension
>
class to the  setcallbackfunction as it is down in PHP with
>
> array(&$this, '_htmlentities')
>

I usually find reading the source for standard library functions to be
helpful for learning how to do things. array_map could help with capturing
a callable and then doing something with it:
https://github.com/php/php-src/blob/master/ext/standard/array.c#L6005

so the PHP Class with opcache ist equal faste as my extension.
> My goal was to write the class as an extension to get faster.
>

Is the constructor where the bulk of the computation happens? Given that
this is a templating tool, it's probably during render. My guess of what
you'd get out of rewriting in C is greater control over string manipulation
and related memory allocation.

That said, if you're hitting performance issues, I might suggest looking
into another templating tool that's more actively maintained. Extensions
are generally harder to maintain than userland code. If you succeed in
writing a faster version of this tool, this could turn into a "now you have
two problems" situation[1]. If at all possible, it'd be better to let an
existing community solve performance issues for you.

The last question should I use call_user_function or write this function
> in C.
>

Call the internal function directly for less overhead.

Hope this helps!

Adam

---
[1] http://regex.info/blog/2006-09-15/247

Reply via email to