[sysprof] libsysprof: add is_empty() helper



commit 59c2fb4b64a231def1a2ae446ab59ae76cb6ed0c
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 15 16:56:12 2019 -0700

    libsysprof: add is_empty() helper
    
    This can be bound easier should we support GIR in the future.

 src/libsysprof-ui/sysprof-callgraph-view.c | 4 +++-
 src/libsysprof/sysprof-callgraph-profile.c | 8 ++++++++
 src/libsysprof/sysprof-callgraph-profile.h | 2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/src/libsysprof-ui/sysprof-callgraph-view.c b/src/libsysprof-ui/sysprof-callgraph-view.c
index 27f848d..1221add 100644
--- a/src/libsysprof-ui/sysprof-callgraph-view.c
+++ b/src/libsysprof-ui/sysprof-callgraph-view.c
@@ -177,9 +177,11 @@ sysprof_callgraph_view_load (SysprofCallgraphView    *self,
   if (!g_set_object (&priv->profile, profile))
     return;
 
-  if (!(stash = sysprof_callgraph_profile_get_stash (profile)))
+  if (sysprof_callgraph_profile_is_empty (profile))
     return;
 
+  stash = sysprof_callgraph_profile_get_stash (profile);
+
   for (n = stack_stash_get_root (stash); n; n = n->siblings)
     state.profile_size += n->total;
 
diff --git a/src/libsysprof/sysprof-callgraph-profile.c b/src/libsysprof/sysprof-callgraph-profile.c
index 84b6375..7caa5b8 100644
--- a/src/libsysprof/sysprof-callgraph-profile.c
+++ b/src/libsysprof/sysprof-callgraph-profile.c
@@ -511,6 +511,14 @@ sysprof_callgraph_profile_get_stash (SysprofCallgraphProfile *self)
   return self->stash;
 }
 
+gboolean
+sysprof_callgraph_profile_is_empty (SysprofCallgraphProfile *self)
+{
+  g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_PROFILE (self), FALSE);
+
+  return self->stash == NULL;
+}
+
 GQuark
 sysprof_callgraph_profile_get_tag (SysprofCallgraphProfile *self,
                               const gchar        *symbol)
diff --git a/src/libsysprof/sysprof-callgraph-profile.h b/src/libsysprof/sysprof-callgraph-profile.h
index 0674eff..94ed460 100644
--- a/src/libsysprof/sysprof-callgraph-profile.h
+++ b/src/libsysprof/sysprof-callgraph-profile.h
@@ -41,6 +41,8 @@ SysprofProfile *sysprof_callgraph_profile_new                (void);
 SYSPROF_AVAILABLE_IN_ALL
 SysprofProfile *sysprof_callgraph_profile_new_with_selection (SysprofSelection        *selection);
 SYSPROF_AVAILABLE_IN_ALL
+gboolean        sysprof_callgraph_profile_is_empty           (SysprofCallgraphProfile *self);
+SYSPROF_AVAILABLE_IN_ALL
 gpointer        sysprof_callgraph_profile_get_stash          (SysprofCallgraphProfile *self);
 SYSPROF_AVAILABLE_IN_ALL
 GQuark          sysprof_callgraph_profile_get_tag            (SysprofCallgraphProfile *self,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]