Browse Source

Merge pull request #70350 from Chaosus/stringname_operator

Add missing != operator to `StringName`
Rémi Verschelde 2 years ago
parent
commit
4f3ec4121a

+ 4 - 0
core/string/string_name.cpp

@@ -169,6 +169,10 @@ bool StringName::operator!=(const String &p_name) const {
 	return !(operator==(p_name));
 	return !(operator==(p_name));
 }
 }
 
 
+bool StringName::operator!=(const char *p_name) const {
+	return !(operator==(p_name));
+}
+
 bool StringName::operator!=(const StringName &p_name) const {
 bool StringName::operator!=(const StringName &p_name) const {
 	// the real magic of all this mess happens here.
 	// the real magic of all this mess happens here.
 	// this is why path comparisons are very fast
 	// this is why path comparisons are very fast

+ 1 - 0
core/string/string_name.h

@@ -102,6 +102,7 @@ public:
 	bool operator==(const String &p_name) const;
 	bool operator==(const String &p_name) const;
 	bool operator==(const char *p_name) const;
 	bool operator==(const char *p_name) const;
 	bool operator!=(const String &p_name) const;
 	bool operator!=(const String &p_name) const;
+	bool operator!=(const char *p_name) const;
 
 
 	_FORCE_INLINE_ bool is_node_unique_name() const {
 	_FORCE_INLINE_ bool is_node_unique_name() const {
 		if (!_data) {
 		if (!_data) {

+ 1 - 1
editor/plugins/visual_shader_editor_plugin.cpp

@@ -1263,7 +1263,7 @@ Dictionary VisualShaderEditor::get_custom_node_data(Ref<VisualShaderNodeCustom>
 
 
 void VisualShaderEditor::update_custom_type(const Ref<Resource> &p_resource) {
 void VisualShaderEditor::update_custom_type(const Ref<Resource> &p_resource) {
 	Ref<Script> scr = Ref<Script>(p_resource.ptr());
 	Ref<Script> scr = Ref<Script>(p_resource.ptr());
-	if (scr.is_null() || scr->get_instance_base_type() != String("VisualShaderNodeCustom")) {
+	if (scr.is_null() || scr->get_instance_base_type() != "VisualShaderNodeCustom") {
 		return;
 		return;
 	}
 	}
 
 

+ 1 - 1
servers/rendering/shader_language.cpp

@@ -4417,7 +4417,7 @@ bool ShaderLanguage::_is_operator_assign(Operator p_op) const {
 }
 }
 
 
 bool ShaderLanguage::_validate_varying_assign(ShaderNode::Varying &p_varying, String *r_message) {
 bool ShaderLanguage::_validate_varying_assign(ShaderNode::Varying &p_varying, String *r_message) {
-	if (current_function != String("vertex") && current_function != String("fragment")) {
+	if (current_function != "vertex" && current_function != "fragment") {
 		*r_message = vformat(RTR("Varying may not be assigned in the '%s' function."), current_function);
 		*r_message = vformat(RTR("Varying may not be assigned in the '%s' function."), current_function);
 		return false;
 		return false;
 	}
 	}