From ef49296716275267a31254d043f137e9c60aeb1b Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Wed, 23 May 2001 10:20:56 +0000 Subject: [PATCH] Tiny speed improvement suggested by noon@users.sourceforge.net. 2001-05-23 Sebastian Wilhelmi * garray.c (g_array_remove_index_fast): Tiny speed improvement suggested by noon@users.sourceforge.net. * glib/tmpl/arrays.sgml, glib/tmpl/arrays_pointers.sgml, glib/tmpl/arrays_byte.sgml: Corrected documentation for the ..._sized_new functions. Discovered by noon@users.sourceforge.net. --- ChangeLog | 5 +++++ ChangeLog.pre-2-0 | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-12 | 5 +++++ ChangeLog.pre-2-2 | 5 +++++ ChangeLog.pre-2-4 | 5 +++++ ChangeLog.pre-2-6 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ docs/reference/ChangeLog | 6 ++++++ docs/reference/glib/tmpl/arrays.sgml | 7 +++++-- docs/reference/glib/tmpl/arrays_byte.sgml | 8 +++++--- docs/reference/glib/tmpl/arrays_pointer.sgml | 7 +++++-- garray.c | 6 +++--- glib/garray.c | 6 +++--- 14 files changed, 67 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd6afb25..84a686fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-05-23 Sebastian Wilhelmi + + * garray.c (g_array_remove_index_fast): Tiny speed improvement + suggested by noon@users.sourceforge.net. + 2001-05-22 Sebastian Wilhelmi * config.h.win32.in: Removed POSIX_*. Defined G_THREAD_SOURCE to diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index cd6afb25..84a686fb 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,8 @@ +2001-05-23 Sebastian Wilhelmi + + * garray.c (g_array_remove_index_fast): Tiny speed improvement + suggested by noon@users.sourceforge.net. + 2001-05-22 Sebastian Wilhelmi * config.h.win32.in: Removed POSIX_*. Defined G_THREAD_SOURCE to diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index cd6afb25..84a686fb 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2001-05-23 Sebastian Wilhelmi + + * garray.c (g_array_remove_index_fast): Tiny speed improvement + suggested by noon@users.sourceforge.net. + 2001-05-22 Sebastian Wilhelmi * config.h.win32.in: Removed POSIX_*. Defined G_THREAD_SOURCE to diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index cd6afb25..84a686fb 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +2001-05-23 Sebastian Wilhelmi + + * garray.c (g_array_remove_index_fast): Tiny speed improvement + suggested by noon@users.sourceforge.net. + 2001-05-22 Sebastian Wilhelmi * config.h.win32.in: Removed POSIX_*. Defined G_THREAD_SOURCE to diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index cd6afb25..84a686fb 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,8 @@ +2001-05-23 Sebastian Wilhelmi + + * garray.c (g_array_remove_index_fast): Tiny speed improvement + suggested by noon@users.sourceforge.net. + 2001-05-22 Sebastian Wilhelmi * config.h.win32.in: Removed POSIX_*. Defined G_THREAD_SOURCE to diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index cd6afb25..84a686fb 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +2001-05-23 Sebastian Wilhelmi + + * garray.c (g_array_remove_index_fast): Tiny speed improvement + suggested by noon@users.sourceforge.net. + 2001-05-22 Sebastian Wilhelmi * config.h.win32.in: Removed POSIX_*. Defined G_THREAD_SOURCE to diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index cd6afb25..84a686fb 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +2001-05-23 Sebastian Wilhelmi + + * garray.c (g_array_remove_index_fast): Tiny speed improvement + suggested by noon@users.sourceforge.net. + 2001-05-22 Sebastian Wilhelmi * config.h.win32.in: Removed POSIX_*. Defined G_THREAD_SOURCE to diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index cd6afb25..84a686fb 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +2001-05-23 Sebastian Wilhelmi + + * garray.c (g_array_remove_index_fast): Tiny speed improvement + suggested by noon@users.sourceforge.net. + 2001-05-22 Sebastian Wilhelmi * config.h.win32.in: Removed POSIX_*. Defined G_THREAD_SOURCE to diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index c07a45fd..113ba61a 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,9 @@ +2001-05-23 Sebastian Wilhelmi + + * glib/tmpl/arrays.sgml, glib/tmpl/arrays_pointers.sgml, + glib/tmpl/arrays_byte.sgml: Corrected documentation for the + ..._sized_new functions. Discovered by noon@users.sourceforge.net. + 2001-05-19 Havoc Pennington * glib/Makefile.am (IGNORE_HFILES): add glibintl.h diff --git a/docs/reference/glib/tmpl/arrays.sgml b/docs/reference/glib/tmpl/arrays.sgml index 2bd14307..981ee5bb 100644 --- a/docs/reference/glib/tmpl/arrays.sgml +++ b/docs/reference/glib/tmpl/arrays.sgml @@ -79,13 +79,16 @@ when they are allocated. -Creates a new #GArray with the given size. +Creates a new #GArray with @reserved_size elements +preallocated. This avoids frequent reallocation, if you are going to +add many elements to the array. Note however that the size of the +array is still 0. @zero_terminated: %TRUE if the array should have an extra element at the end with all bits cleared @clear: %TRUE if all bits in the array should be cleared to 0 on allocation @element_size: size of each element in the array -@reserved_size: initial array size (number of elements) +@reserved_size: number of elements preallocated @Returns: the new #GArray diff --git a/docs/reference/glib/tmpl/arrays_byte.sgml b/docs/reference/glib/tmpl/arrays_byte.sgml index 2303e1a8..340f03ab 100644 --- a/docs/reference/glib/tmpl/arrays_byte.sgml +++ b/docs/reference/glib/tmpl/arrays_byte.sgml @@ -68,11 +68,13 @@ Creates a new #GByteArray. -Creates a new byte array, with the given size. +Creates a new #GByteArray with @reserved_size bytes preallocated. This +avoids frequent reallocation, if you are going to add many bytes to +the array. Note however that the size of the array is still 0. -@reserved_size: initial number of bytes in the array -@Returns: a new #GByteArray +@reserved_size: number of bytes preallocated +@Returns: the new #GByteArray diff --git a/docs/reference/glib/tmpl/arrays_pointer.sgml b/docs/reference/glib/tmpl/arrays_pointer.sgml index fbe1a3d0..35c3d79b 100644 --- a/docs/reference/glib/tmpl/arrays_pointer.sgml +++ b/docs/reference/glib/tmpl/arrays_pointer.sgml @@ -82,10 +82,13 @@ Creates a new #GPtrArray. -Creates a new #GPtrArray with @reserved_size elements. +Creates a new #GPtrArray with @reserved_size pointers +preallocated. This avoids frequent reallocation, if you are going to +add many pointers to the array. Note however that the size of the +array is still 0. -@reserved_size: Initial number of elements. +@reserved_size: number of pointers preallocated. @Returns: the new #GPtrArray. diff --git a/garray.c b/garray.c index 9f32b760..9d65fca8 100644 --- a/garray.c +++ b/garray.c @@ -254,9 +254,9 @@ g_array_remove_index_fast (GArray* farray, g_return_val_if_fail (index < array->len, NULL); if (index != array->len - 1) - g_memmove (g_array_elt_pos (array, index), - g_array_elt_pos (array, array->len - 1), - g_array_elt_len (array, 1)); + memcpy (g_array_elt_pos (array, index), + g_array_elt_pos (array, array->len - 1), + g_array_elt_len (array, 1)); array->len -= 1; diff --git a/glib/garray.c b/glib/garray.c index 9f32b760..9d65fca8 100644 --- a/glib/garray.c +++ b/glib/garray.c @@ -254,9 +254,9 @@ g_array_remove_index_fast (GArray* farray, g_return_val_if_fail (index < array->len, NULL); if (index != array->len - 1) - g_memmove (g_array_elt_pos (array, index), - g_array_elt_pos (array, array->len - 1), - g_array_elt_len (array, 1)); + memcpy (g_array_elt_pos (array, index), + g_array_elt_pos (array, array->len - 1), + g_array_elt_len (array, 1)); array->len -= 1; -- 2.34.1