use FirstOrDefault() in linq query instead of Where().

This commit is contained in:
morkt 2015-08-14 06:09:04 +04:00
parent ba6b8b4f8e
commit 5830c0d8a2

View File

@ -101,18 +101,18 @@ namespace GameRes.Formats.MAI
var offset = file.View.ReadUInt32 (index_offset+0x10); var offset = file.View.ReadUInt32 (index_offset+0x10);
var entry = new AutoEntry (Path.Combine (current_folder, name), () => { var entry = new AutoEntry (Path.Combine (current_folder, name), () => {
uint signature = file.View.ReadUInt32 (offset); uint signature = file.View.ReadUInt32 (offset);
IEnumerable<IResource> res;
if (is_mask_arc) if (is_mask_arc)
res = FormatCatalog.Instance.ImageFormats.Where (x => x.Tag == "MSK/MAI"); return FormatCatalog.Instance.ImageFormats.FirstOrDefault (x => x.Tag == "MSK/MAI");
else if (0x4d43 == (signature & 0xffff)) // 'CM' else if (0x4d43 == (signature & 0xffff)) // 'CM'
res = FormatCatalog.Instance.ImageFormats.Where (x => x.Tag == "CMP/MAI"); return FormatCatalog.Instance.ImageFormats.FirstOrDefault (x => x.Tag == "CMP/MAI");
else if (0x4d41 == (signature & 0xffff)) // 'AM' else if (0x4d41 == (signature & 0xffff)) // 'AM'
res = FormatCatalog.Instance.ImageFormats.Where (x => x.Tag == "AM/MAI"); return FormatCatalog.Instance.ImageFormats.FirstOrDefault (x => x.Tag == "AM/MAI");
else if (0x4d42 == (signature & 0xffff)) // 'BM' else if (0x4d42 == (signature & 0xffff)) // 'BM'
res = FormatCatalog.Instance.ImageFormats.Where (x => x.Tag == "BMP"); return ImageFormat.Bmp;
else if (signature != 0)
return FormatCatalog.Instance.LookupSignature (signature).FirstOrDefault();
else else
res = FormatCatalog.Instance.LookupSignature (signature); return null;
return res.FirstOrDefault();
}); });
entry.Offset = offset; entry.Offset = offset;
entry.Size = file.View.ReadUInt32 (index_offset+0x14); entry.Size = file.View.ReadUInt32 (index_offset+0x14);