mirror of
https://github.com/godotengine/godot.git
synced 2025-04-13 01:00:35 +08:00
Merge pull request #100033 from Daylily-Zeleen/daylily-zeleen/optimize_callable_to_string
Optimize callable's stringify text.
This commit is contained in:
commit
9c290c4c56
@ -361,8 +361,12 @@ Callable::operator String() const {
|
||||
if (base) {
|
||||
String class_name = base->get_class();
|
||||
Ref<Script> script = base->get_script();
|
||||
if (script.is_valid() && script->get_path().is_resource_file()) {
|
||||
class_name += "(" + script->get_path().get_file() + ")";
|
||||
if (script.is_valid()) {
|
||||
if (!script->get_global_name().is_empty()) {
|
||||
class_name += "(" + script->get_global_name() + ")";
|
||||
} else if (script->get_path().is_resource_file()) {
|
||||
class_name += "(" + script->get_path().get_file() + ")";
|
||||
}
|
||||
}
|
||||
return class_name + "::" + String(method);
|
||||
} else {
|
||||
|
@ -178,12 +178,12 @@ uint32_t GDScriptLambdaSelfCallable::hash() const {
|
||||
|
||||
String GDScriptLambdaSelfCallable::get_as_text() const {
|
||||
if (function == nullptr) {
|
||||
return "<invalid lambda>";
|
||||
return "<invalid self lambda>";
|
||||
}
|
||||
if (function->get_name() != StringName()) {
|
||||
return function->get_name().operator String() + "(lambda)";
|
||||
return function->get_name().operator String() + "(self lambda)";
|
||||
}
|
||||
return "(anonymous lambda)";
|
||||
return "(anonymous self lambda)";
|
||||
}
|
||||
|
||||
CallableCustom::CompareEqualFunc GDScriptLambdaSelfCallable::get_compare_equal_func() const {
|
||||
|
@ -49,7 +49,14 @@ uint32_t GDScriptRPCCallable::hash() const {
|
||||
String GDScriptRPCCallable::get_as_text() const {
|
||||
String class_name = object->get_class();
|
||||
Ref<Script> script = object->get_script();
|
||||
return class_name + "(" + script->get_path().get_file() + ")::" + String(method) + " (rpc)";
|
||||
if (script.is_valid()) {
|
||||
if (!script->get_global_name().is_empty()) {
|
||||
class_name += "(" + script->get_global_name() + ")";
|
||||
} else if (script->get_path().is_resource_file()) {
|
||||
class_name += "(" + script->get_path().get_file() + ")";
|
||||
}
|
||||
}
|
||||
return class_name + "::" + String(method) + " (rpc)";
|
||||
}
|
||||
|
||||
CallableCustom::CompareEqualFunc GDScriptRPCCallable::get_compare_equal_func() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user