summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2020-08-24 13:48:24 +0200
committerMarco Trevisan <mail@3v1n0.net>2023-04-10 17:09:09 +0000
commit0251634f16de5419ec1f6546b3df5b5b6a723ea4 (patch)
tree32c6addc6ebec9bfd37969571a8fe6efa668d693
parent99f56c0696b5e2ca9fd1c967d5bbe0b4848c7d69 (diff)
downloadgobject-introspection-0251634f16de5419ec1f6546b3df5b5b6a723ea4.tar.gz
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
-rw-r--r--girepository/gitypelib-internal.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h
index 494ab2b3..4ba53a2a 100644
--- a/girepository/gitypelib-internal.h
+++ b/girepository/gitypelib-internal.h
@@ -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.