Use G_LIKELY. (#69022)

* glib/gmessages.h (g_return_if_fail):
	(g_return_val_if_fail): Use G_LIKELY.  (#69022)

	* glib/gmacros.h (G_LIKELY):
	(G_UNLIKELY): New macros for hinting the compiler about the
	expected result of expressions. For gcc 3.x, define these
	using __builtin_expect.  (#69022)

	* glib/tmpl/macros_misc.sgml: Document G_LIKELY, G_UNLIKELY.

	* glib/glib-sections.txt: Add G_LIKELY, G_UNLIKELY.
This commit is contained in:
Matthias Clasen
2002-11-20 21:50:16 +00:00
parent 17cff0324d
commit dc645ce354
12 changed files with 126 additions and 4 deletions

View File

@@ -1,3 +1,9 @@
2002-11-20 Matthias Clasen <maclas@gmx.de>
* glib/tmpl/macros_misc.sgml: Document G_LIKELY, G_UNLIKELY.
* glib/glib-sections.txt: Add G_LIKELY, G_UNLIKELY.
2002-10-20 Matthias Clasen <maclas@gmx.de>
* gobject/Makefile.am (SCANOBJ_FILES):

View File

@@ -296,6 +296,10 @@ G_GNUC_FUNCTION
G_GNUC_PRETTY_FUNCTION
G_GNUC_NO_INSTRUMENT
<SUBSECTION>
G_LIKELY
G_UNLIKELY
<SUBSECTION>
G_STRLOC

View File

@@ -237,6 +237,32 @@ See the GNU C documentation for details.
<!-- ##### MACRO G_LIKELY ##### -->
<para>
Hints the compiler that the expression is likely to evaluate to a true
value. The compiler may use this information for optimizations.
</para>
<informalexample><programlisting>
if (G_LIKELY (random () != 1))
g_print ("not one");
</programlisting></informalexample>
@expr: the expression
<!-- ##### MACRO G_UNLIKELY ##### -->
<para>
Hints the compiler that the expression is unlikely to evaluate to a true
value. The compiler may use this information for optimizations.
</para>
<informalexample><programlisting>
if (G_UNLIKELY (random () == 1))
g_print ("a random one");
</programlisting></informalexample>
@expr: the expression
<!-- ##### MACRO G_STRLOC ##### -->
<para>
Expands to a string identifying the current code position.