[libgit2-glib] Use a switch to convert native object to ggit object type



commit 5700adcd32e35ddbe2ff7342a0fd8ac9267e120c
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Thu Jul 12 11:16:20 2012 +0200

    Use a switch to convert native object to ggit object type

 libgit2-glib/ggit-utils.c |   28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/libgit2-glib/ggit-utils.c b/libgit2-glib/ggit-utils.c
index 96fded3..5ab505c 100644
--- a/libgit2-glib/ggit-utils.c
+++ b/libgit2-glib/ggit-utils.c
@@ -81,29 +81,23 @@ GgitObject *
 ggit_utils_create_real_object (git_object *obj,
                                gboolean    owned)
 {
-	GgitObject *object = NULL;
 	git_otype otype;
 
 	otype = git_object_type (obj);
 
-	if (otype == GIT_OBJ_TAG)
+	switch (otype)
 	{
-		object = GGIT_OBJECT (_ggit_tag_wrap ((git_tag *)obj, owned));
-	}
-	else if (otype == GGIT_TYPE_BLOB)
-	{
-		object = GGIT_OBJECT (_ggit_blob_wrap ((git_blob *)obj, owned));
-	}
-	else if (otype == GIT_OBJ_COMMIT)
-	{
-		object = GGIT_OBJECT (_ggit_commit_wrap ((git_commit *)obj, owned));
-	}
-	else if (otype == GIT_OBJ_TREE)
-	{
-		object = GGIT_OBJECT (_ggit_tree_wrap ((git_tree *)obj, owned));
+		case GIT_OBJ_TAG:
+			return GGIT_OBJECT (_ggit_tag_wrap ((git_tag *)obj, owned));
+		case GIT_OBJ_BLOB:
+			return GGIT_OBJECT (_ggit_blob_wrap ((git_blob *)obj, owned));
+		case GIT_OBJ_COMMIT:
+			return GGIT_OBJECT (_ggit_commit_wrap ((git_commit *)obj, owned));
+		case GIT_OBJ_TREE:
+			return GGIT_OBJECT (_ggit_tree_wrap ((git_tree *)obj, owned));
+		default:
+			return NULL;
 	}
-
-	return object;
 }
 
 gchar **



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