Re: GHash small patch
- From: Sven Neumann <sven gimp org>
- To: Salmaso Raffaele <raffaele salmaso libero it>
- Cc: gtk-devel-list gnome org
- Subject: Re: GHash small patch
- Date: 15 Mar 2002 18:24:40 +0100
Hi,
Salmaso Raffaele <raffaele salmaso libero it> writes:
> A very little patch to avoid 3 function call when not needed.
>
> --- ghash.c Mon Dec 17 15:26:02 2001
> +++ ghash-new.c Fri Mar 15 09:09:56 2002
> @@ -585,9 +585,12 @@
> gint new_size;
> gint i;
>
> - new_size = CLAMP(g_spaced_primes_closest (hash_table->nnodes),
> - HASH_TABLE_MIN_SIZE,
> - HASH_TABLE_MAX_SIZE);
> + new_size = g_spaced_primes_closest (hash_table->nnodes);
> + if (new_size < HASH_TABLE_MIN_SIZE)
> + new_size = HASH_TABLE_MIN_SIZE;
> + else if (new_size > HASH_TABLE_MAX_SIZE)
> + new_size = HASH_TABLE_MAX_SIZE;
> +
> new_nodes = g_new0 (GHashNode*, new_size);
>
> for (i = 0; i < hash_table->size; i++)
or even (for readability):
--- glib/ghash.c 16 Dec 2001 19:31:36 -0000 1.31
+++ glib/ghash.c 15 Mar 2002 17:24:01 -0000
@@ -585,9 +585,9 @@ g_hash_table_resize (GHashTable *hash_ta
gint new_size;
gint i;
- new_size = CLAMP(g_spaced_primes_closest (hash_table->nnodes),
- HASH_TABLE_MIN_SIZE,
- HASH_TABLE_MAX_SIZE);
+ new_size = g_spaced_primes_closest (hash_table->nnodes);
+ new_size = CLAMP (new_size, HASH_TABLE_MIN_SIZE, HASH_TABLE_MAX_SIZE);
+
new_nodes = g_new0 (GHashNode*, new_size);
for (i = 0; i < hash_table->size; i++)
Salut, Sven
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]