Merge pull request #50855 from raulsntos/csharp-use-array-empty
Use `Array.Empty` instead of allocating a every time
This commit is contained in:
commit
f0de042aaa
@ -76,9 +76,9 @@ namespace GodotTools.Export
|
|||||||
GlobalDef("mono/export/aot/use_interpreter", true);
|
GlobalDef("mono/export/aot/use_interpreter", true);
|
||||||
|
|
||||||
// --aot or --aot=opt1,opt2 (use 'mono --aot=help AuxAssembly.dll' to list AOT options)
|
// --aot or --aot=opt1,opt2 (use 'mono --aot=help AuxAssembly.dll' to list AOT options)
|
||||||
GlobalDef("mono/export/aot/extra_aot_options", new string[] { });
|
GlobalDef("mono/export/aot/extra_aot_options", Array.Empty<string>());
|
||||||
// --optimize/-O=opt1,opt2 (use 'mono --list-opt'' to list optimize options)
|
// --optimize/-O=opt1,opt2 (use 'mono --list-opt'' to list optimize options)
|
||||||
GlobalDef("mono/export/aot/extra_optimizer_options", new string[] { });
|
GlobalDef("mono/export/aot/extra_optimizer_options", Array.Empty<string>());
|
||||||
|
|
||||||
GlobalDef("mono/export/aot/android_toolchain_path", "");
|
GlobalDef("mono/export/aot/android_toolchain_path", "");
|
||||||
}
|
}
|
||||||
@ -298,8 +298,8 @@ namespace GodotTools.Export
|
|||||||
LLVMOutputPath = "",
|
LLVMOutputPath = "",
|
||||||
FullAot = platform == OS.Platforms.iOS || (bool)(ProjectSettings.GetSetting("mono/export/aot/full_aot") ?? false),
|
FullAot = platform == OS.Platforms.iOS || (bool)(ProjectSettings.GetSetting("mono/export/aot/full_aot") ?? false),
|
||||||
UseInterpreter = (bool)ProjectSettings.GetSetting("mono/export/aot/use_interpreter"),
|
UseInterpreter = (bool)ProjectSettings.GetSetting("mono/export/aot/use_interpreter"),
|
||||||
ExtraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options") ?? new string[] { },
|
ExtraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options") ?? Array.Empty<string>(),
|
||||||
ExtraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options") ?? new string[] { },
|
ExtraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options") ?? Array.Empty<string>(),
|
||||||
ToolchainPath = aotToolchainPath
|
ToolchainPath = aotToolchainPath
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace GodotTools.Ides.Rider
|
|||||||
GD.PushWarning(e.Message);
|
GD.PushWarning(e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RiderInfo[0];
|
return Array.Empty<RiderInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RiderInfo[] CollectAllRiderPathsLinux()
|
private static RiderInfo[] CollectAllRiderPathsLinux()
|
||||||
@ -249,7 +249,7 @@ namespace GodotTools.Ides.Rider
|
|||||||
bool isMac)
|
bool isMac)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(toolboxRiderRootPath))
|
if (!Directory.Exists(toolboxRiderRootPath))
|
||||||
return new string[0];
|
return Array.Empty<string>();
|
||||||
|
|
||||||
var channelDirs = Directory.GetDirectories(toolboxRiderRootPath);
|
var channelDirs = Directory.GetDirectories(toolboxRiderRootPath);
|
||||||
var paths = channelDirs.SelectMany(channelDir =>
|
var paths = channelDirs.SelectMany(channelDir =>
|
||||||
@ -295,7 +295,7 @@ namespace GodotTools.Ides.Rider
|
|||||||
Logger.Warn($"Failed to get RiderPath from {channelDir}", e);
|
Logger.Warn($"Failed to get RiderPath from {channelDir}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new string[0];
|
return Array.Empty<string>();
|
||||||
})
|
})
|
||||||
.Where(c => !string.IsNullOrEmpty(c))
|
.Where(c => !string.IsNullOrEmpty(c))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
@ -306,7 +306,7 @@ namespace GodotTools.Ides.Rider
|
|||||||
{
|
{
|
||||||
var folder = new DirectoryInfo(Path.Combine(buildDir, dirName));
|
var folder = new DirectoryInfo(Path.Combine(buildDir, dirName));
|
||||||
if (!folder.Exists)
|
if (!folder.Exists)
|
||||||
return new string[0];
|
return Array.Empty<string>();
|
||||||
|
|
||||||
if (!isMac)
|
if (!isMac)
|
||||||
return new[] { Path.Combine(folder.FullName, searchPattern) }.Where(File.Exists).ToArray();
|
return new[] { Path.Combine(folder.FullName, searchPattern) }.Where(File.Exists).ToArray();
|
||||||
|
@ -111,7 +111,7 @@ namespace GodotTools.Utils
|
|||||||
|
|
||||||
private static string PathWhichWindows([NotNull] string name)
|
private static string PathWhichWindows([NotNull] string name)
|
||||||
{
|
{
|
||||||
string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? new string[] { };
|
string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? Array.Empty<string>();
|
||||||
string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep);
|
string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep);
|
||||||
|
|
||||||
var searchDirs = new List<string>();
|
var searchDirs = new List<string>();
|
||||||
|
@ -1737,7 +1737,12 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
|
|||||||
cs_in_statements += " : ";
|
cs_in_statements += " : ";
|
||||||
}
|
}
|
||||||
|
|
||||||
String def_arg = sformat(iarg.default_argument, arg_type->cs_type);
|
String cs_type = arg_type->cs_type;
|
||||||
|
if (cs_type.ends_with("[]")) {
|
||||||
|
cs_type = cs_type.substr(0, cs_type.length() - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
String def_arg = sformat(iarg.default_argument, cs_type);
|
||||||
|
|
||||||
cs_in_statements += def_arg;
|
cs_in_statements += def_arg;
|
||||||
cs_in_statements += ";\n" INDENT3;
|
cs_in_statements += ";\n" INDENT3;
|
||||||
@ -1746,8 +1751,10 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
|
|||||||
|
|
||||||
// Apparently the name attribute must not include the @
|
// Apparently the name attribute must not include the @
|
||||||
String param_tag_name = iarg.name.begins_with("@") ? iarg.name.substr(1, iarg.name.length()) : iarg.name;
|
String param_tag_name = iarg.name.begins_with("@") ? iarg.name.substr(1, iarg.name.length()) : iarg.name;
|
||||||
|
// Escape < and > in the attribute default value
|
||||||
|
String param_def_arg = def_arg.replacen("<", "<").replacen(">", ">");
|
||||||
|
|
||||||
default_args_doc.append(MEMBER_BEGIN "/// <param name=\"" + param_tag_name + "\">If the parameter is null, then the default value is " + def_arg + "</param>");
|
default_args_doc.append(MEMBER_BEGIN "/// <param name=\"" + param_tag_name + "\">If the parameter is null, then the default value is " + param_def_arg + "</param>");
|
||||||
} else {
|
} else {
|
||||||
icall_params += arg_type->cs_in.is_empty() ? iarg.name : sformat(arg_type->cs_in, iarg.name);
|
icall_params += arg_type->cs_in.is_empty() ? iarg.name : sformat(arg_type->cs_in, iarg.name);
|
||||||
}
|
}
|
||||||
@ -3072,6 +3079,9 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
|
|||||||
r_iarg.default_argument = "null";
|
r_iarg.default_argument = "null";
|
||||||
break;
|
break;
|
||||||
case Variant::ARRAY:
|
case Variant::ARRAY:
|
||||||
|
r_iarg.default_argument = "new %s { }";
|
||||||
|
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
|
||||||
|
break;
|
||||||
case Variant::PACKED_BYTE_ARRAY:
|
case Variant::PACKED_BYTE_ARRAY:
|
||||||
case Variant::PACKED_INT32_ARRAY:
|
case Variant::PACKED_INT32_ARRAY:
|
||||||
case Variant::PACKED_INT64_ARRAY:
|
case Variant::PACKED_INT64_ARRAY:
|
||||||
@ -3081,7 +3091,7 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
|
|||||||
case Variant::PACKED_VECTOR2_ARRAY:
|
case Variant::PACKED_VECTOR2_ARRAY:
|
||||||
case Variant::PACKED_VECTOR3_ARRAY:
|
case Variant::PACKED_VECTOR3_ARRAY:
|
||||||
case Variant::PACKED_COLOR_ARRAY:
|
case Variant::PACKED_COLOR_ARRAY:
|
||||||
r_iarg.default_argument = "new %s {}";
|
r_iarg.default_argument = "Array.Empty<%s>()";
|
||||||
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
|
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
|
||||||
break;
|
break;
|
||||||
case Variant::TRANSFORM2D: {
|
case Variant::TRANSFORM2D: {
|
||||||
|
Loading…
Reference in New Issue
Block a user