Improve some usages of Aggregate.

This commit is contained in:
RoosterDragon
2017-12-22 12:55:53 +00:00
committed by abcdefg30
parent adc4538c44
commit 63810220e4
4 changed files with 6 additions and 6 deletions

View File

@@ -160,7 +160,7 @@ namespace OpenRA
/// <summary>Replace special character prefixes with full paths.</summary>
public static string ResolvePath(params string[] path)
{
return ResolvePath(path.Aggregate(Path.Combine));
return ResolvePath(Path.Combine(path));
}
/// <summary>

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
writer.Write(Encoding.ASCII.GetBytes("XCC by Olaf van der Spek"));
writer.Write(new byte[] { 0x1A, 0x04, 0x17, 0x27, 0x10, 0x19, 0x80, 0x00 });
writer.Write(Entries.Aggregate(Entries.Length, (a, b) => a + b.Length) + 52); // Size
writer.Write(Entries.Sum(e => e.Length) + Entries.Length + 52); // Size
writer.Write(0); // Type
writer.Write(0); // Version
writer.Write(0); // Game/Format (0 == TD)

View File

@@ -313,7 +313,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
var tileset = Game.ModData.DefaultTileSets[map.Tileset];
var mapSection = file.GetSection("IsoMapPack5");
var data = Convert.FromBase64String(mapSection.Aggregate(string.Empty, (a, b) => a + b.Value));
var data = Convert.FromBase64String(string.Concat(mapSection.Select(kvp => kvp.Value)));
int cells = (fullSize.X * 2 - 1) * fullSize.Y;
int lzoPackSize = cells * 11 + 4; // last 4 bytes contains a lzo pack header saying no more data is left
var isoMapPack = new byte[lzoPackSize];
@@ -349,13 +349,13 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
static void ReadOverlay(Map map, IniFile file, int2 fullSize)
{
var overlaySection = file.GetSection("OverlayPack");
var overlayCompressed = Convert.FromBase64String(overlaySection.Aggregate(string.Empty, (a, b) => a + b.Value));
var overlayCompressed = Convert.FromBase64String(string.Concat(overlaySection.Select(kvp => kvp.Value)));
var overlayPack = new byte[1 << 18];
var temp = new byte[1 << 18];
UnpackLCW(overlayCompressed, overlayPack, temp);
var overlayDataSection = file.GetSection("OverlayDataPack");
var overlayDataCompressed = Convert.FromBase64String(overlayDataSection.Aggregate(string.Empty, (a, b) => a + b.Value));
var overlayDataCompressed = Convert.FromBase64String(string.Concat(overlayDataSection.Select(kvp => kvp.Value)));
var overlayDataPack = new byte[1 << 18];
UnpackLCW(overlayDataCompressed, overlayDataPack, temp);

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
{
int old;
powerDrain.TryGetValue(a, out old); // old is 0 if a is not in powerDrain
var amount = a.TraitsImplementing<Power>().Where(t => !t.IsTraitDisabled).Aggregate(0, (v, p) => v + p.GetEnabledPower());
var amount = a.TraitsImplementing<Power>().Where(t => !t.IsTraitDisabled).Sum(p => p.GetEnabledPower());
powerDrain[a] = amount;
if (amount == old || devMode.UnlimitedPower)
return;