Skip to content

Commit dec68ae

Browse files
committed
no need to create a new list all the time
1 parent 0eb6155 commit dec68ae

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

UnturnedImages/Vehicles/VehicleImageDirectory.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,7 @@ public UniTask HandleEventAsync(object? sender, PluginConfigurationChangedEvent
228228
return null;
229229
}
230230

231-
private List<Color32> GetPaintColors(VehicleAsset asset)
232-
{
233-
if (asset.DefaultPaintColors != null)
234-
return asset.DefaultPaintColors;
235-
236-
return new List<Color32>()
231+
private static readonly List<Color32> _defaultColors = new List<Color32>()
237232
{
238233
new Color32(53, 53, 53, 1), // black
239234
new Color32(55, 101, 140, 1), // blue
@@ -244,6 +239,13 @@ private List<Color32> GetPaintColors(VehicleAsset asset)
244239
new Color32(212, 212, 212, 1), // white
245240
new Color32(205, 170, 30, 1) // yellow
246241
};
242+
243+
private List<Color32> GetPaintColors(VehicleAsset asset)
244+
{
245+
if (asset.DefaultPaintColors != null)
246+
return asset.DefaultPaintColors;
247+
248+
return _defaultColors;
247249
}
248250
}
249251
}

tools/UnturnedImages.Module/Images/CustomVehicleTool.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,7 @@ private void Update()
216216
Destroy(vehicleParent.gameObject);
217217
}
218218

219-
private List<Color32> GetPaintColors(VehicleAsset asset)
220-
{
221-
if (asset.DefaultPaintColors != null && asset.DefaultPaintColors.Count > 0)
222-
return asset.DefaultPaintColors;
223-
224-
return new List<Color32>()
219+
private static readonly List<Color32> _defaultColors = new List<Color32>()
225220
{
226221
new Color32(53, 53, 53, 1), // black
227222
new Color32(55, 101, 140, 1), // blue
@@ -232,6 +227,13 @@ private List<Color32> GetPaintColors(VehicleAsset asset)
232227
new Color32(212, 212, 212, 1), // white
233228
new Color32(205, 170, 30, 1) // yellow
234229
};
230+
231+
private List<Color32> GetPaintColors(VehicleAsset asset)
232+
{
233+
if (asset.DefaultPaintColors != null)
234+
return asset.DefaultPaintColors;
235+
236+
return _defaultColors;
235237
}
236238
}
237239
}

0 commit comments

Comments
 (0)