From 20a350eacc343356ec070afb335f3e503c32e1d5 Mon Sep 17 00:00:00 2001 From: "Gergely Polonkai (W00d5t0ck)" Date: Fri, 4 Oct 2013 01:00:26 +0200 Subject: [PATCH] Small performance fixes Removed some unnecessary checks --- src/gswe-aspect-data.c | 24 ++++-------------------- src/gswe-aspect-info.c | 22 ++++++---------------- src/gswe-moon-phase-data.c | 12 ++---------- src/gswe-sign-info.c | 10 ++++------ 4 files changed, 16 insertions(+), 52 deletions(-) diff --git a/src/gswe-aspect-data.c b/src/gswe-aspect-data.c index 492e5ea..79f0346 100644 --- a/src/gswe-aspect-data.c +++ b/src/gswe-aspect-data.c @@ -239,11 +239,7 @@ gswe_aspect_data_set_planet2(GsweAspectData *aspect_data, GswePlanetData *planet GswePlanetData * gswe_aspect_data_get_planet2(GsweAspectData *aspect_data) { - if (aspect_data) { - return aspect_data->planet2; - } else { - return NULL; - } + return aspect_data->planet2; } /** @@ -257,11 +253,7 @@ gswe_aspect_data_get_planet2(GsweAspectData *aspect_data) gdouble gswe_aspect_data_get_distance(GsweAspectData *aspect_data) { - if (aspect_data) { - return aspect_data->distance; - } else { - return -1.0; - } + return aspect_data->distance; } /** @@ -293,11 +285,7 @@ gswe_aspect_data_get_aspect(GsweAspectData *aspect_data) GsweAspectInfo * gswe_aspect_data_get_aspect_info(GsweAspectData *aspect_data) { - if (aspect_data) { - return aspect_data->aspect_info; - } else { - return NULL; - } + return aspect_data->aspect_info; } /** @@ -311,10 +299,6 @@ gswe_aspect_data_get_aspect_info(GsweAspectData *aspect_data) gdouble gswe_aspect_data_get_difference(GsweAspectData *aspect_data) { - if (aspect_data) { - return aspect_data->difference; - } else { - return -1.0; - } + return aspect_data->difference; } diff --git a/src/gswe-aspect-info.c b/src/gswe-aspect-info.c index 28d1421..e306597 100644 --- a/src/gswe-aspect-info.c +++ b/src/gswe-aspect-info.c @@ -42,13 +42,11 @@ G_DEFINE_BOXED_TYPE(GsweAspectInfo, gswe_aspect_info, (GBoxedCopyFunc)gswe_aspec static void gswe_aspect_info_free(GsweAspectInfo *aspect_info) { - if (aspect_info) { - if (aspect_info->name) { - g_free(aspect_info->name); - } - - g_free(aspect_info); + if (aspect_info->name) { + g_free(aspect_info->name); } + + g_free(aspect_info); } /** @@ -240,11 +238,7 @@ gswe_aspect_info_set_harmonic(GsweAspectInfo *aspect_info, gboolean harmonic) gboolean gswe_aspect_info_get_harmonic(GsweAspectInfo *aspect_info) { - if (aspect_info) { - return aspect_info->harmonic; - } else { - return FALSE; - } + return aspect_info->harmonic; } /** @@ -273,10 +267,6 @@ gswe_aspect_info_set_major(GsweAspectInfo *aspect_info, gboolean major) gboolean gswe_aspect_info_get_major(GsweAspectInfo *aspect_info) { - if (aspect_info) { - return aspect_info->major; - } else { - return FALSE; - } + return aspect_info->major; } diff --git a/src/gswe-moon-phase-data.c b/src/gswe-moon-phase-data.c index dc4975e..6783ff3 100644 --- a/src/gswe-moon-phase-data.c +++ b/src/gswe-moon-phase-data.c @@ -93,11 +93,7 @@ gswe_moon_phase_data_unref(GsweMoonPhaseData *moon_phase_data) GsweMoonPhase gswe_moon_phase_data_get_phase(GsweMoonPhaseData *moon_phase_data) { - if (moon_phase_data) { - return moon_phase_data->phase; - } else { - return GSWE_MOON_PHASE_NONE; - } + return moon_phase_data->phase; } /** @@ -111,10 +107,6 @@ gswe_moon_phase_data_get_phase(GsweMoonPhaseData *moon_phase_data) gdouble gswe_moon_phase_data_get_illumination(GsweMoonPhaseData *moon_phase_data) { - if (moon_phase_data) { - return moon_phase_data->illumination; - } else { - return 0.0; - } + return moon_phase_data->illumination; } diff --git a/src/gswe-sign-info.c b/src/gswe-sign-info.c index b0d4ee6..c2ca1d8 100644 --- a/src/gswe-sign-info.c +++ b/src/gswe-sign-info.c @@ -35,13 +35,11 @@ G_DEFINE_BOXED_TYPE(GsweSignInfo, gswe_sign_info, (GBoxedCopyFunc)gswe_sign_info static void gswe_sign_info_free(GsweSignInfo *sign_info) { - if (sign_info) { - if (sign_info->name) { - g_free(sign_info->name); - } - - g_free(sign_info); + if (sign_info->name) { + g_free(sign_info->name); } + + g_free(sign_info); } /**