GtkSharp
GtkSharp copied to clipboard
optimize array empty & avoid empty list creation in ctor
replaced new[0] with array empty in non-generated code
in GapiCodegen/Ctor.cs: if no fitting parameters found, use Array.Empty
Examples:
Before:
if (GetType () != typeof (NoOpObject)) {
var vals = new List<GLib.Value> ();
var names = new List<string> ();
CreateNativeObject (names.ToArray (), vals.ToArray ());
return;
}
After:
if (GetType () != typeof (NoOpObject)) {
CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
return;
}
if no nullable parameters found, use Array Initializer instead of list
Examples:
Before:
if (GetType () != typeof (SimplePermission)) {
var vals = new List<GLib.Value> ();
var names = new List<string> ();
names.Add ("allowed");
vals.Add (new GLib.Value (allowed));
CreateNativeObject (names.ToArray (), vals.ToArray ());
return;
}
after:
if (GetType () != typeof (SimplePermission)) {
CreateNativeObject (
new[] {"allowed"},
new[] {new GLib.Value (allowed)}
);
return;
}