[gnome-builder] clang: code style cleanup



commit d89e0c6bb722d9556da056f02c5dca69ec398530
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jan 9 17:32:47 2018 -0800

    clang: code style cleanup

 src/plugins/clang/ide-clang-symbol-node.c      |   16 +++++++---------
 src/plugins/clang/ide-clang-translation-unit.c |   12 ++++++------
 2 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/plugins/clang/ide-clang-symbol-node.c b/src/plugins/clang/ide-clang-symbol-node.c
index 477e6a3..42e4fcf 100644
--- a/src/plugins/clang/ide-clang-symbol-node.c
+++ b/src/plugins/clang/ide-clang-symbol-node.c
@@ -171,22 +171,22 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode       *symbol_node,
                                           gpointer             user_data)
 {
   IdeClangSymbolNode *self = (IdeClangSymbolNode *)symbol_node;
-  IdeSourceLocation *ret;
+  g_autoptr(IdeFile) ifile = NULL;
+  g_autoptr(GFile) gfile = NULL;
+  g_autoptr(GTask) task = NULL;
   IdeContext *context;
   const gchar *filename;
   CXString cxfilename;
   CXSourceLocation cxloc;
   CXFile file;
-  GFile *gfile;
-  IdeFile *ifile;
   guint line = 0;
   guint line_offset = 0;
-  g_autoptr(GTask) task = NULL;
 
   g_return_if_fail (IDE_IS_CLANG_SYMBOL_NODE (self));
 
   task = g_task_new (self, cancellable, callback, user_data);
   g_task_set_source_tag (task, ide_clang_symbol_node_get_location_async);
+  g_task_set_priority (task, G_PRIORITY_LOW);
 
   cxloc = clang_getCursorLocation (self->cursor);
   clang_getFileLocation (cxloc, &file, &line, &line_offset, NULL);
@@ -204,13 +204,11 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode       *symbol_node,
                         "context", context,
                         NULL);
 
-  ret = ide_source_location_new (ifile, line-1, line_offset-1, 0);
+  g_task_return_pointer (task,
+                         ide_source_location_new (ifile, line-1, line_offset-1, 0),
+                         (GDestroyNotify)ide_source_location_unref);
 
-  g_clear_object (&ifile);
-  g_clear_object (&gfile);
   clang_disposeString (cxfilename);
-
-  g_task_return_pointer (task, ret, (GDestroyNotify)ide_source_location_unref);
 }
 
 static IdeSourceLocation *
diff --git a/src/plugins/clang/ide-clang-translation-unit.c b/src/plugins/clang/ide-clang-translation-unit.c
index e5cb6e5..f0324dd 100644
--- a/src/plugins/clang/ide-clang-translation-unit.c
+++ b/src/plugins/clang/ide-clang-translation-unit.c
@@ -1112,7 +1112,7 @@ ide_clang_translation_unit_get_symbol_tree_async (IdeClangTranslationUnit *self,
                                                   gpointer                 user_data)
 {
   g_autoptr(GTask) task = NULL;
-  IdeSymbolTree *symbol_tree;
+  g_autoptr(IdeSymbolTree) symbol_tree = NULL;
   IdeContext *context;
 
   g_return_if_fail (IDE_IS_CLANG_TRANSLATION_UNIT (self));
@@ -1120,6 +1120,8 @@ ide_clang_translation_unit_get_symbol_tree_async (IdeClangTranslationUnit *self,
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
   task = g_task_new (self, cancellable, callback, user_data);
+  g_task_set_source_tag (task, ide_clang_translation_unit_get_symbol_tree_async);
+  g_task_set_priority (task, G_PRIORITY_LOW);
 
   context = ide_object_get_context (IDE_OBJECT (self));
   symbol_tree = g_object_new (IDE_TYPE_CLANG_SYMBOL_TREE,
@@ -1127,7 +1129,7 @@ ide_clang_translation_unit_get_symbol_tree_async (IdeClangTranslationUnit *self,
                               "native", self->native,
                               "file", file,
                               NULL);
-  g_task_return_pointer (task, symbol_tree, g_object_unref);
+  g_task_return_pointer (task, g_steal_pointer (&symbol_tree), g_object_unref);
 }
 
 IdeSymbolTree *
@@ -1135,12 +1137,10 @@ ide_clang_translation_unit_get_symbol_tree_finish (IdeClangTranslationUnit  *sel
                                                    GAsyncResult             *result,
                                                    GError                  **error)
 {
-  GTask *task = (GTask *)result;
-
   g_return_val_if_fail (IDE_IS_CLANG_TRANSLATION_UNIT (self), NULL);
-  g_return_val_if_fail (G_IS_TASK (task), NULL);
+  g_return_val_if_fail (G_IS_TASK (result), NULL);
 
-  return g_task_propagate_pointer (task, error);
+  return g_task_propagate_pointer (G_TASK (result), error);
 }
 
 static gboolean


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