mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-29 20:34:11 +02:00
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:
@@ -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):
|
||||
|
@@ -296,6 +296,10 @@ G_GNUC_FUNCTION
|
||||
G_GNUC_PRETTY_FUNCTION
|
||||
G_GNUC_NO_INSTRUMENT
|
||||
|
||||
<SUBSECTION>
|
||||
G_LIKELY
|
||||
G_UNLIKELY
|
||||
|
||||
<SUBSECTION>
|
||||
G_STRLOC
|
||||
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user