Przeglądaj źródła

Simplify code to add settings to global lists

Daniele Bartolini 12 lat temu
rodzic
commit
3694540b22

+ 3 - 7
engine/core/settings/FloatSetting.cpp

@@ -43,16 +43,12 @@ FloatSetting::FloatSetting(const char* name, const char* synopsis, float value,
 {
 	*this = value;
 
-	if (g_float_settings_head == NULL)
-	{
-		g_float_settings_head = this;
-		m_next = NULL;
-	}
-	else
+	if (g_float_settings_head != NULL)
 	{
 		m_next = g_float_settings_head;
-		g_float_settings_head = this;
 	}
+
+	g_float_settings_head = this;
 }
 
 //-----------------------------------------------------------------------------

+ 3 - 7
engine/core/settings/IntSetting.cpp

@@ -43,16 +43,12 @@ IntSetting::IntSetting(const char* name, const char* synopsis, int32_t value, in
 {
 	*this = value;
 
-	if (g_int_settings_head == NULL)
-	{
-		g_int_settings_head = this;
-		m_next = NULL;
-	}
-	else
+	if (g_int_settings_head != NULL)
 	{
 		m_next = g_int_settings_head;
-		g_int_settings_head = this;
 	}
+
+	g_int_settings_head = this;
 }
 
 //-----------------------------------------------------------------------------

+ 3 - 7
engine/core/settings/StringSetting.cpp

@@ -41,16 +41,12 @@ StringSetting::StringSetting(const char* name, const char* synopsis, const char*
 {
 	*this = value;
 
-	if (g_string_settings_head == NULL)
-	{
-		g_string_settings_head = this;
-		m_next = NULL;
-	}
-	else
+	if (g_string_settings_head != NULL)
 	{
 		m_next = g_string_settings_head;
-		g_string_settings_head = this;
 	}
+
+	g_string_settings_head = this;
 }
 
 //-----------------------------------------------------------------------------