You are viewing hughsient

Technical Blog of Richard Hughes - GLib gperf

Richard Hughes
Date: 2008-04-02 02:07
Subject: GLib gperf
Security: Public
Dear Lazyweb,

Is there a more modern, GLib'ish version of gperf? I want to go from string->enum and emun->string faster than just using strcmp in a loop. I don't think I want to use GHashTable as it needs to be bi-directional. I like nice compact simple C code, and don't like awk in makefiles. Ideas?

Richard.
Post A Comment | 4 Comments | Share | Link






Hubert Figuiere
User: hub_
Date: 2008-04-02 03:02 (UTC)
Subject: (no subject)
what's wrong with gperf?
Reply | Thread | Link



fragglet: Chocolate Doom
User: fragglet
Date: 2008-04-02 08:53 (UTC)
Subject: Exactly
Keyword:Chocolate Doom
Why reinvent the wheel? Is it really /that/ important to have a dependency on glib?
Reply | Parent | Thread | Link



Hubert Figuiere
User: hub_
Date: 2008-04-02 17:09 (UTC)
Subject: Re: Exactly
maybe we should rename it kperf ;-)
Reply | Parent | Thread | Link



Matthew Barnes
User: mbarnes
Date: 2008-04-02 04:44 (UTC)
Subject: (no subject)
I've used an array of interned string pointers before for this sort of thing. enum->string is O(1) (array index lookup), string->enum is O(n) (compare string pointers for equality) plus a hash table lookup when calling g_intern_string() on the input string. The downside is you have to initialize the array at runtime.
Reply | Thread | Link



browse
my journal
April 2008