bug-gperf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gperf] gperf as a library


From: Bruno Haible
Subject: Re: [bug-gperf] gperf as a library
Date: Thu, 05 Sep 2019 01:51:32 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-159-generic; KDE/5.18.0; x86_64; ; )

Hi Mark,

> I had one suggestion about usability and four suggestions about performance.

Only one issue per mail thread, please! Otherwise discussions become
unmanageable and/or are not goal-directed.

> USABILITY SUGGESTION ( VERY INVOLVED and/or DIFFICULT )
> 
>   I would like to have a limited version of gperf which could be invoked
> while running C or C++. I don't know how to do this,
> but I understand what possible syntax might be.
> 
>    struct gperf
>    {
>       unsigned long MAX_WORD_LENGTH;
>       unsigned long MIN_WORD_LENGTH;
>       unsigned long MAX_HASH_VALUE:
>       unsigned long MIN_HASH_VALUE;
>       unsigned char * alloc_array;
>       unsigned long * shifts; // 0 and 1 in the the perm2.gperf in
> examples directory
>       char ** words; // to borrow, but not own, an array.
>   };
> 
>  char *the[] = { "hi", "there",""}; // I don't know if this is
> syntactically correct.
> // The "" acts as a "end of list" identifier
>  gperf x;
>   initialize_gperf(&x,the);
>   unsigned int n1 = hash( "there", 5, x);
>   unsigned int n2 = hash("dude",4, x);
>   assert( n1 ); // found
>   assert( ! n2 ); // not found
>   destroy_gperf(x); // freeing alloc_array  and shifts, but not words

What does the 'gperf' type contain?

If it contains just the arrays, you lose at least a factor of 2
through the "interpreter" that does the computations according to
the values in the arrays.

If it contains machine code, then you need to link with GNU lightning,
libgccjit, or LLVM - and then you have linked in a lot of libraries
and accepted platform constraints. Not to forget the system calls needed
for putting the generated code into executable memory. Is that worth it?

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]