mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-01 16:56:18 +01:00
gitypelib-internal: Use a switch to check if blob is a registered type
No need to go through all the possible blob types, while we can use an inline function to check it. Use an attribute to ensure the function will be inlined, when this is not available just fallback to the previous definition
This commit is contained in:
parent
92bbb0033b
commit
fcd2026506
@ -185,6 +185,32 @@ typedef enum {
|
||||
BLOB_TYPE_UNION
|
||||
} GTypelibBlobType;
|
||||
|
||||
|
||||
#if defined (G_CAN_INLINE) && defined (G_ALWAYS_INLINE)
|
||||
|
||||
G_ALWAYS_INLINE
|
||||
inline gboolean
|
||||
_blob_is_registered_type (GTypelibBlobType blob_type)
|
||||
{
|
||||
switch (blob_type)
|
||||
{
|
||||
case BLOB_TYPE_STRUCT:
|
||||
case BLOB_TYPE_UNION:
|
||||
case BLOB_TYPE_ENUM:
|
||||
case BLOB_TYPE_FLAGS:
|
||||
case BLOB_TYPE_OBJECT:
|
||||
case BLOB_TYPE_INTERFACE:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#define BLOB_IS_REGISTERED_TYPE(blob) \
|
||||
_blob_is_registered_type ((GTypelibBlobType) (blob)->blob_type)
|
||||
|
||||
#else
|
||||
|
||||
#define BLOB_IS_REGISTERED_TYPE(blob) \
|
||||
((blob)->blob_type == BLOB_TYPE_STRUCT || \
|
||||
(blob)->blob_type == BLOB_TYPE_UNION || \
|
||||
@ -193,6 +219,8 @@ typedef enum {
|
||||
(blob)->blob_type == BLOB_TYPE_OBJECT || \
|
||||
(blob)->blob_type == BLOB_TYPE_INTERFACE)
|
||||
|
||||
#endif /* defined (G_CAN_INLINE) && defined (G_ALWAYS_INLINE) */
|
||||
|
||||
/**
|
||||
* Header:
|
||||
* @magic: See #G_IR_MAGIC.
|
||||
|
Loading…
Reference in New Issue
Block a user