Re: g_strcase_hash & G_GET_DOUBLE_LE suggestion
- From: Tim Janik <timj gtk org>
- To: gtk-devel-list redhat com
- Subject: Re: g_strcase_hash & G_GET_DOUBLE_LE suggestion
- Date: Sun, 15 Aug 1999 22:56:23 +0200 (CEST)
On Sun, 15 Aug 1999, Bertrand Guiheneuf wrote:
>
> michael@imaginator.com said:
> //
> // I sent this some time ago and either it is more worthless than I
> // suspected or it bounced silently; anyway here goes:
>
> // Something we use in gnumeric is a case insensitive string
> // hash, so attached is a patch for that ( perhaps this is a stupid idea
> // ? ) it doesn't fit the namespace so nicely as g_strcase_hash but I
> // don't know what to do about that.
>
> I defined exactely the same in gnome-mailer/camel, (except that I did not
> use tolower because of a comment in g_strcasecmp() ). Perhaps wouldn't it
> be too stupid to add it to glib.
it probably wouldn't hurt much to add g_strcase_hash() and g_strcase_equal()
to glib, but that is not the prefered way to implement case insensitive
string lookups. because of the character conversion that has to be performed
for all hashes and comparisions, you are by far better off wrapping your
hash table accessors, so they only insert lower case strings and only
lookup lower case strings. so instead of
result = g_hash_table_lookup (my_strcase_ht, U_and_l_string);
you'd do:
gchar *tmp = g_strdup (U_and_l_string);
g_strdown (tmp);
result = g_hash_table_lookup (my_strcase_ht, tmp);
g_free (tmp);
that way you only need *one* case conversion per lookup and don't pay
the penalty of case conversions in the hash function and succesive
comparisions (which are often required to find the correct node
for non-unique hashes).
>
> Regards,
>
> Bertrand
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]