On Tuesday 25 February 2003 23:36, Balazs Scheidler wrote:
On Tue, Feb 25, 2003 at 11:24:38PM +0100, Achim Gsell wrote:
On Monday 24 February 2003 13:03, Roberto Nibali wrote: You can also test & try the attached "macro.c" which uses a hash function generated with gperf. In my tests the binary search made the macro expansion (4 macros in the template) about 2.5 times faster and the hash function (and some other minor changes) about 3 times.
The real solution for further improvements would be to preprocess the template description and cache the results. A template is a sequence of:
constant_string macro constant_string macro ...
e.g. a single pass would be enough to convert the string to an internal format representing the sequence above, then a much faster algorithm could be used to format the results as no lookups would be needed. (macros could be stored as looked up macro ids)
Yes, of course ...
I plan something like this in syslog-ng 2, as the basic infrastructure is there, it would however be a bit more difficult for 1.5.x.
I had the same idea and this was the reason I didn't implemented it yet! But may be we should use one of the faster algorithms as a fist shot. Achim