mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
Eliminate use of floating point when determining if the hash table needs
Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com> * glib/ghash.c: Eliminate use of floating point when determining if the hash table needs to be resized, and also factor out the test from g_hash_table_resize() to save function calls for the common case. (#59124) * glib/gmain.c (g_main_context_query): Document the return value.
This commit is contained in:
parent
6d4342990a
commit
8079eb3456
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Eliminate use of floating point when
|
||||||
|
determining if the hash table needs to be resized,
|
||||||
|
and also factor out the test from g_hash_table_resize()
|
||||||
|
to save function calls for the common case.
|
||||||
|
(#59124)
|
||||||
|
|
||||||
|
* glib/gmain.c (g_main_context_query): Document the
|
||||||
|
return value.
|
||||||
|
|
||||||
2001-08-19 Darin Adler <darin@bentspoon.com>
|
2001-08-19 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Eliminate use of floating point when
|
||||||
|
determining if the hash table needs to be resized,
|
||||||
|
and also factor out the test from g_hash_table_resize()
|
||||||
|
to save function calls for the common case.
|
||||||
|
(#59124)
|
||||||
|
|
||||||
|
* glib/gmain.c (g_main_context_query): Document the
|
||||||
|
return value.
|
||||||
|
|
||||||
2001-08-19 Darin Adler <darin@bentspoon.com>
|
2001-08-19 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Eliminate use of floating point when
|
||||||
|
determining if the hash table needs to be resized,
|
||||||
|
and also factor out the test from g_hash_table_resize()
|
||||||
|
to save function calls for the common case.
|
||||||
|
(#59124)
|
||||||
|
|
||||||
|
* glib/gmain.c (g_main_context_query): Document the
|
||||||
|
return value.
|
||||||
|
|
||||||
2001-08-19 Darin Adler <darin@bentspoon.com>
|
2001-08-19 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Eliminate use of floating point when
|
||||||
|
determining if the hash table needs to be resized,
|
||||||
|
and also factor out the test from g_hash_table_resize()
|
||||||
|
to save function calls for the common case.
|
||||||
|
(#59124)
|
||||||
|
|
||||||
|
* glib/gmain.c (g_main_context_query): Document the
|
||||||
|
return value.
|
||||||
|
|
||||||
2001-08-19 Darin Adler <darin@bentspoon.com>
|
2001-08-19 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Eliminate use of floating point when
|
||||||
|
determining if the hash table needs to be resized,
|
||||||
|
and also factor out the test from g_hash_table_resize()
|
||||||
|
to save function calls for the common case.
|
||||||
|
(#59124)
|
||||||
|
|
||||||
|
* glib/gmain.c (g_main_context_query): Document the
|
||||||
|
return value.
|
||||||
|
|
||||||
2001-08-19 Darin Adler <darin@bentspoon.com>
|
2001-08-19 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Eliminate use of floating point when
|
||||||
|
determining if the hash table needs to be resized,
|
||||||
|
and also factor out the test from g_hash_table_resize()
|
||||||
|
to save function calls for the common case.
|
||||||
|
(#59124)
|
||||||
|
|
||||||
|
* glib/gmain.c (g_main_context_query): Document the
|
||||||
|
return value.
|
||||||
|
|
||||||
2001-08-19 Darin Adler <darin@bentspoon.com>
|
2001-08-19 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Eliminate use of floating point when
|
||||||
|
determining if the hash table needs to be resized,
|
||||||
|
and also factor out the test from g_hash_table_resize()
|
||||||
|
to save function calls for the common case.
|
||||||
|
(#59124)
|
||||||
|
|
||||||
|
* glib/gmain.c (g_main_context_query): Document the
|
||||||
|
return value.
|
||||||
|
|
||||||
2001-08-19 Darin Adler <darin@bentspoon.com>
|
2001-08-19 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Aug 19 21:32:39 2001 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* glib/ghash.c: Eliminate use of floating point when
|
||||||
|
determining if the hash table needs to be resized,
|
||||||
|
and also factor out the test from g_hash_table_resize()
|
||||||
|
to save function calls for the common case.
|
||||||
|
(#59124)
|
||||||
|
|
||||||
|
* glib/gmain.c (g_main_context_query): Document the
|
||||||
|
return value.
|
||||||
|
|
||||||
2001-08-19 Darin Adler <darin@bentspoon.com>
|
2001-08-19 Darin Adler <darin@bentspoon.com>
|
||||||
|
|
||||||
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
* glib/gshell.c: (g_shell_quote): Added missing \ character.
|
||||||
|
27
glib/ghash.c
27
glib/ghash.c
@ -59,6 +59,14 @@ struct _GHashTable
|
|||||||
GDestroyNotify value_destroy_func;
|
GDestroyNotify value_destroy_func;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define G_HASH_TABLE_RESIZE(hash_table) \
|
||||||
|
G_STMT_START { \
|
||||||
|
if ((hash_table->size >= 3 * hash_table->nnodes && \
|
||||||
|
hash_table->size > HASH_TABLE_MIN_SIZE) || \
|
||||||
|
(3 * hash_table->size <= hash_table->nnodes && \
|
||||||
|
hash_table->size < HASH_TABLE_MAX_SIZE)) \
|
||||||
|
g_hash_table_resize (hash_table); \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
static void g_hash_table_resize (GHashTable *hash_table);
|
static void g_hash_table_resize (GHashTable *hash_table);
|
||||||
static GHashNode** g_hash_table_lookup_node (GHashTable *hash_table,
|
static GHashNode** g_hash_table_lookup_node (GHashTable *hash_table,
|
||||||
@ -304,7 +312,7 @@ g_hash_table_insert (GHashTable *hash_table,
|
|||||||
{
|
{
|
||||||
*node = g_hash_node_new (key, value);
|
*node = g_hash_node_new (key, value);
|
||||||
hash_table->nnodes++;
|
hash_table->nnodes++;
|
||||||
g_hash_table_resize (hash_table);
|
G_HASH_TABLE_RESIZE (hash_table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +355,7 @@ g_hash_table_replace (GHashTable *hash_table,
|
|||||||
{
|
{
|
||||||
*node = g_hash_node_new (key, value);
|
*node = g_hash_node_new (key, value);
|
||||||
hash_table->nnodes++;
|
hash_table->nnodes++;
|
||||||
g_hash_table_resize (hash_table);
|
G_HASH_TABLE_RESIZE (hash_table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +391,7 @@ g_hash_table_remove (GHashTable *hash_table,
|
|||||||
hash_table->value_destroy_func);
|
hash_table->value_destroy_func);
|
||||||
hash_table->nnodes--;
|
hash_table->nnodes--;
|
||||||
|
|
||||||
g_hash_table_resize (hash_table);
|
G_HASH_TABLE_RESIZE (hash_table);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -417,7 +425,7 @@ g_hash_table_steal (GHashTable *hash_table,
|
|||||||
g_hash_node_destroy (dest, NULL, NULL);
|
g_hash_node_destroy (dest, NULL, NULL);
|
||||||
hash_table->nnodes--;
|
hash_table->nnodes--;
|
||||||
|
|
||||||
g_hash_table_resize (hash_table);
|
G_HASH_TABLE_RESIZE (hash_table);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -517,7 +525,7 @@ g_hash_table_foreach_remove_or_steal (GHashTable *hash_table,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_resize (hash_table);
|
G_HASH_TABLE_RESIZE (hash_table);
|
||||||
|
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
@ -570,17 +578,10 @@ g_hash_table_resize (GHashTable *hash_table)
|
|||||||
GHashNode **new_nodes;
|
GHashNode **new_nodes;
|
||||||
GHashNode *node;
|
GHashNode *node;
|
||||||
GHashNode *next;
|
GHashNode *next;
|
||||||
gfloat nodes_per_list;
|
|
||||||
guint hash_val;
|
guint hash_val;
|
||||||
gint new_size;
|
gint new_size;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
nodes_per_list = (gfloat) hash_table->nnodes / (gfloat) hash_table->size;
|
|
||||||
|
|
||||||
if ((nodes_per_list > 0.3 || hash_table->size <= HASH_TABLE_MIN_SIZE) &&
|
|
||||||
(nodes_per_list < 3.0 || hash_table->size >= HASH_TABLE_MAX_SIZE))
|
|
||||||
return;
|
|
||||||
|
|
||||||
new_size = CLAMP(g_spaced_primes_closest (hash_table->nnodes),
|
new_size = CLAMP(g_spaced_primes_closest (hash_table->nnodes),
|
||||||
HASH_TABLE_MIN_SIZE,
|
HASH_TABLE_MIN_SIZE,
|
||||||
HASH_TABLE_MAX_SIZE);
|
HASH_TABLE_MAX_SIZE);
|
||||||
|
@ -1944,7 +1944,9 @@ g_main_context_prepare (GMainContext *context,
|
|||||||
*
|
*
|
||||||
* Determines information necessary to poll this main loop.
|
* Determines information necessary to poll this main loop.
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value: the number of records actually stored in @fds,
|
||||||
|
* or, if more than @n_fds records need to be stored, the number
|
||||||
|
* of records that need to be stored.
|
||||||
**/
|
**/
|
||||||
gint
|
gint
|
||||||
g_main_context_query (GMainContext *context,
|
g_main_context_query (GMainContext *context,
|
||||||
|
Loading…
Reference in New Issue
Block a user