libctf: add ctf_forwardable_kind
authorNick Alcock <nick.alcock@oracle.com>
Wed, 3 Jun 2020 12:23:42 +0000 (13:23 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 22 Jul 2020 16:57:48 +0000 (17:57 +0100)
The internals of the deduplicator want to know if something is a type
that can have a forward to it fairly often, often enough that inlining
it brings a noticeable performance gain.  Convert the one place in
libctf that can already benefit, even though it doesn't bring any sort
of performance gain there.

libctf/
* ctf-inlines.h (ctf_forwardable_kind): New.
* ctf-create.c (ctf_add_forward): Use it.

libctf/ChangeLog
libctf/ctf-create.c
libctf/ctf-inlines.h

index b3a816cb862971a64291d7bbe32594001ef07029..c22cba0d84a257adf4397db1d8b3ec989dad6bc1 100644 (file)
@@ -1,3 +1,8 @@
+2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-inlines.h (ctf_forwardable_kind): New.
+       * ctf-create.c (ctf_add_forward): Use it.
+
 2020-07-22  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-impl.h (ctf_get_ctt_size): Move definition from here...
index c13b83d4d3b02d8c45104e31e9291115aa44a692..d50367d6de31cf97580cbd319d799d718608b783 100644 (file)
@@ -1241,7 +1241,7 @@ ctf_add_forward (ctf_file_t *fp, uint32_t flag, const char *name,
   ctf_dtdef_t *dtd;
   ctf_id_t type = 0;
 
-  if (kind != CTF_K_STRUCT && kind != CTF_K_UNION && kind != CTF_K_ENUM)
+  if (!ctf_forwardable_kind (kind))
     return (ctf_set_errno (fp, ECTF_NOTSUE));
 
   /* If the type is already defined or exists as a forward tag, just
index 4bec97b11b3f2eba792139500d0d31acd22a6217..3b912bd9a25f7a11181cb3971e97e8dda1f98ab8 100644 (file)
@@ -40,6 +40,12 @@ ctf_get_ctt_size (const ctf_file_t *fp,
   return (fp->ctf_fileops->ctfo_get_ctt_size (fp, tp, sizep, incrementp));
 }
 
+static inline int
+ctf_forwardable_kind (int kind)
+{
+  return (kind == CTF_K_STRUCT || kind == CTF_K_UNION || kind == CTF_K_ENUM);
+}
+
 
 static inline int
 ctf_dynhash_cinsert (ctf_dynhash_t *h, const void *k, const void *v)
This page took 0.029405 seconds and 4 git commands to generate.