+2005-02-04 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/tmpl/linked_lists_double.sgml:
+ * glib/tmpl/linked_lists_single.sgml: Add a note
+ regarding inefficiency of repeated appends. (#166271,
+ Olivier Sessink)
+
2005-02-03 Matthias Clasen <mclasen@redhat.com>
* glib/tmpl/quarks.sgml: Add a warning against
<!-- ##### STRUCT GList ##### -->
<para>
The #GList struct is used for each element in a doubly-linked list.
-The <structfield>data</structfield> field holds the element's data, which can
-be a pointer to any kind of data, or any integer value using the
-<link linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>.
-The <structfield>next</structfield> and <structfield>prev</structfield>
-pointers are the links to the next and previous elements in the list.
</para>
-@data:
-@next:
-@prev:
+@data: holds the element's data, which can be a pointer to any kind of data,
+ or any integer value using the
+ <link linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>.
+@next: contains the link to the next element in the list.
+@prev: contains the link to the previous element in the list.
<!-- ##### FUNCTION g_list_append ##### -->
<para>
make sure you store the new value.
</para>
</note>
+<note>
+<para>
+Note that g_list_append() has to traverse the entire list to find the end,
+which is inefficient when adding multiple elements. A common idiom to
+avoid the inefficiency is to prepend the elements and reverse the list
+when all elements have been added.
+</para>
+</note>
<informalexample><programlisting>
/* Notice that these are initialized to the empty list. */
GList *list = NULL, *number_list = NULL;
<!-- ##### STRUCT GSList ##### -->
<para>
The #GSList struct is used for each element in the singly-linked list.
-The <structfield>data</structfield> field holds the element's data, which can
-be a pointer to any kind of data, or any integer value using the
-<link linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>.
-The <structfield>next</structfield> field contains the link to the next
-element in the list.
</para>
-@data:
-@next:
+@data: holds the element's data, which can be a pointer to any kind of data,
+ or any integer value using the
+ <link linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>.
+@next: contains the link to the next element in the list.
+
<!-- ##### FUNCTION g_slist_alloc ##### -->
<para>
make sure you store the new value.
</para>
</note>
+<note>
+<para>
+Note that g_slist_append() has to traverse the entire list to find the end,
+which is inefficient when adding multiple elements. A common idiom to
+avoid the inefficiency is to prepend the elements and reverse the list
+when all elements have been added.
+</para>
+</note>
<informalexample><programlisting>
/* Notice that these are initialized to the empty list. */
GSList *list = NULL, *number_list = NULL;