mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Reduce unncessary DB methods
This commit is contained in:
@@ -938,8 +938,6 @@ namespace SabreTools.DatFiles
|
|||||||
var datItems = datFile.ItemsDB.GetItems();
|
var datItems = datFile.ItemsDB.GetItems();
|
||||||
var machines = datFile.GetMachinesDB();
|
var machines = datFile.GetMachinesDB();
|
||||||
var sources = datFile.ItemsDB.GetSources();
|
var sources = datFile.ItemsDB.GetSources();
|
||||||
var itemMachineMappings = datFile.ItemsDB.GetItemMachineMappings();
|
|
||||||
var itemSourceMappings = datFile.ItemsDB.GetItemSourceMappings();
|
|
||||||
|
|
||||||
// Create mappings from old index to new index
|
// Create mappings from old index to new index
|
||||||
var machineRemapping = new Dictionary<long, long>();
|
var machineRemapping = new Dictionary<long, long>();
|
||||||
@@ -969,8 +967,8 @@ namespace SabreTools.DatFiles
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Get the machine and source index for this item
|
// Get the machine and source index for this item
|
||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = datFile.ItemsDB.GetMachineForItem(item.Key).Key;
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = datFile.ItemsDB.GetSourceForItem(item.Key).Key;
|
||||||
|
|
||||||
// If the current item isn't an external duplicate
|
// If the current item isn't an external duplicate
|
||||||
#if NET20 || NET35
|
#if NET20 || NET35
|
||||||
@@ -1178,8 +1176,6 @@ namespace SabreTools.DatFiles
|
|||||||
var datItems = datFile.ItemsDB.GetItems();
|
var datItems = datFile.ItemsDB.GetItems();
|
||||||
var machines = datFile.GetMachinesDB();
|
var machines = datFile.GetMachinesDB();
|
||||||
var sources = datFile.ItemsDB.GetSources();
|
var sources = datFile.ItemsDB.GetSources();
|
||||||
var itemMachineMappings = datFile.ItemsDB.GetItemMachineMappings();
|
|
||||||
var itemSourceMappings = datFile.ItemsDB.GetItemSourceMappings();
|
|
||||||
|
|
||||||
// Create mappings from old index to new index
|
// Create mappings from old index to new index
|
||||||
var machineRemapping = new Dictionary<long, long>();
|
var machineRemapping = new Dictionary<long, long>();
|
||||||
@@ -1219,8 +1215,8 @@ namespace SabreTools.DatFiles
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Get the machine and source index for this item
|
// Get the machine and source index for this item
|
||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = datFile.ItemsDB.GetMachineForItem(item.Key).Key;
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = datFile.ItemsDB.GetSourceForItem(item.Key).Key;
|
||||||
|
|
||||||
// Get the source associated with the item
|
// Get the source associated with the item
|
||||||
var source = datFile.ItemsDB.GetSource(sourceIndex);
|
var source = datFile.ItemsDB.GetSource(sourceIndex);
|
||||||
@@ -1371,8 +1367,6 @@ namespace SabreTools.DatFiles
|
|||||||
var datItems = datFile.ItemsDB.GetItems();
|
var datItems = datFile.ItemsDB.GetItems();
|
||||||
var machines = datFile.GetMachinesDB();
|
var machines = datFile.GetMachinesDB();
|
||||||
var sources = datFile.ItemsDB.GetSources();
|
var sources = datFile.ItemsDB.GetSources();
|
||||||
var itemMachineMappings = datFile.ItemsDB.GetItemMachineMappings();
|
|
||||||
var itemSourceMappings = datFile.ItemsDB.GetItemSourceMappings();
|
|
||||||
|
|
||||||
// Create mappings from old index to new index
|
// Create mappings from old index to new index
|
||||||
var machineRemapping = new Dictionary<long, long>();
|
var machineRemapping = new Dictionary<long, long>();
|
||||||
@@ -1402,8 +1396,8 @@ namespace SabreTools.DatFiles
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Get the machine and source index for this item
|
// Get the machine and source index for this item
|
||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = datFile.ItemsDB.GetMachineForItem(item.Key).Key;
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = datFile.ItemsDB.GetSourceForItem(item.Key).Key;
|
||||||
|
|
||||||
// If the current item isn't a duplicate
|
// If the current item isn't a duplicate
|
||||||
#if NET20 || NET35
|
#if NET20 || NET35
|
||||||
@@ -1547,8 +1541,6 @@ namespace SabreTools.DatFiles
|
|||||||
var datItems = addFrom.ItemsDB.GetItems();
|
var datItems = addFrom.ItemsDB.GetItems();
|
||||||
var machines = addFrom.GetMachinesDB();
|
var machines = addFrom.GetMachinesDB();
|
||||||
var sources = addFrom.ItemsDB.GetSources();
|
var sources = addFrom.ItemsDB.GetSources();
|
||||||
var itemMachineMappings = addFrom.ItemsDB.GetItemMachineMappings();
|
|
||||||
var itemSourceMappings = addFrom.ItemsDB.GetItemSourceMappings();
|
|
||||||
|
|
||||||
// Create mappings from old index to new index
|
// Create mappings from old index to new index
|
||||||
var machineRemapping = new Dictionary<long, long>();
|
var machineRemapping = new Dictionary<long, long>();
|
||||||
@@ -1578,8 +1570,8 @@ namespace SabreTools.DatFiles
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Get the machine and source index for this item
|
// Get the machine and source index for this item
|
||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = addFrom.ItemsDB.GetMachineForItem(item.Key).Key;
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = addFrom.ItemsDB.GetSourceForItem(item.Key).Key;
|
||||||
|
|
||||||
addTo.AddItemDB(item.Value, machineRemapping[machineIndex], sourceRemapping[sourceIndex], statsOnly: false);
|
addTo.AddItemDB(item.Value, machineRemapping[machineIndex], sourceRemapping[sourceIndex], statsOnly: false);
|
||||||
|
|
||||||
@@ -1652,8 +1644,6 @@ namespace SabreTools.DatFiles
|
|||||||
var datItems = datFile.ItemsDB.GetItems();
|
var datItems = datFile.ItemsDB.GetItems();
|
||||||
var machines = datFile.GetMachinesDB();
|
var machines = datFile.GetMachinesDB();
|
||||||
var sources = datFile.ItemsDB.GetSources();
|
var sources = datFile.ItemsDB.GetSources();
|
||||||
var itemMachineMappings = datFile.ItemsDB.GetItemMachineMappings();
|
|
||||||
var itemSourceMappings = datFile.ItemsDB.GetItemSourceMappings();
|
|
||||||
|
|
||||||
// Create mappings from old index to new index
|
// Create mappings from old index to new index
|
||||||
var machineRemapping = new Dictionary<long, long>();
|
var machineRemapping = new Dictionary<long, long>();
|
||||||
@@ -1683,8 +1673,8 @@ namespace SabreTools.DatFiles
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Get the machine and source index for this item
|
// Get the machine and source index for this item
|
||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = datFile.ItemsDB.GetMachineForItem(item.Key).Key;
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = datFile.ItemsDB.GetSourceForItem(item.Key).Key;
|
||||||
|
|
||||||
// Get the source associated with the item
|
// Get the source associated with the item
|
||||||
var source = datFile.ItemsDB.GetSource(sourceIndex);
|
var source = datFile.ItemsDB.GetSource(sourceIndex);
|
||||||
|
|||||||
@@ -368,16 +368,6 @@ namespace SabreTools.DatFiles
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get all item to machine mappings
|
|
||||||
/// </summary>
|
|
||||||
public IDictionary<long, long> GetItemMachineMappings() => _itemToMachineMapping;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get all item to source mappings
|
|
||||||
/// </summary>
|
|
||||||
public IDictionary<long, long> GetItemSourceMappings() => _itemToSourceMapping;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all items and their indicies
|
/// Get all items and their indicies
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -145,8 +145,6 @@ namespace SabreTools.DatTools
|
|||||||
var datItems = datFile.ItemsDB.GetItems();
|
var datItems = datFile.ItemsDB.GetItems();
|
||||||
var machines = datFile.GetMachinesDB();
|
var machines = datFile.GetMachinesDB();
|
||||||
var sources = datFile.ItemsDB.GetSources();
|
var sources = datFile.ItemsDB.GetSources();
|
||||||
var itemMachineMappings = datFile.ItemsDB.GetItemMachineMappings();
|
|
||||||
var itemSourceMappings = datFile.ItemsDB.GetItemSourceMappings();
|
|
||||||
|
|
||||||
// Create mappings from old index to new index
|
// Create mappings from old index to new index
|
||||||
var machineRemapping = new Dictionary<long, long>();
|
var machineRemapping = new Dictionary<long, long>();
|
||||||
@@ -178,8 +176,8 @@ namespace SabreTools.DatTools
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Get the machine and source index for this item
|
// Get the machine and source index for this item
|
||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = datFile.ItemsDB.GetMachineForItem(item.Key).Key;
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = datFile.ItemsDB.GetSourceForItem(item.Key).Key;
|
||||||
|
|
||||||
if (newExtA.Contains((item.Value.GetName() ?? string.Empty).GetNormalizedExtension()))
|
if (newExtA.Contains((item.Value.GetName() ?? string.Empty).GetNormalizedExtension()))
|
||||||
{
|
{
|
||||||
@@ -361,8 +359,6 @@ namespace SabreTools.DatTools
|
|||||||
var datItems = datFile.ItemsDB.GetItems();
|
var datItems = datFile.ItemsDB.GetItems();
|
||||||
var machines = datFile.GetMachinesDB();
|
var machines = datFile.GetMachinesDB();
|
||||||
var sources = datFile.ItemsDB.GetSources();
|
var sources = datFile.ItemsDB.GetSources();
|
||||||
var itemMachineMappings = datFile.ItemsDB.GetItemMachineMappings();
|
|
||||||
var itemSourceMappings = datFile.ItemsDB.GetItemSourceMappings();
|
|
||||||
|
|
||||||
// Create mappings from old index to new index
|
// Create mappings from old index to new index
|
||||||
var machineRemapping = new Dictionary<long, long>();
|
var machineRemapping = new Dictionary<long, long>();
|
||||||
@@ -410,8 +406,8 @@ namespace SabreTools.DatTools
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Get the machine and source index for this item
|
// Get the machine and source index for this item
|
||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = datFile.ItemsDB.GetMachineForItem(item.Key).Key;
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = datFile.ItemsDB.GetSourceForItem(item.Key).Key;
|
||||||
|
|
||||||
// Only process Disk, Media, and Rom
|
// Only process Disk, Media, and Rom
|
||||||
switch (item.Value)
|
switch (item.Value)
|
||||||
@@ -699,8 +695,6 @@ namespace SabreTools.DatTools
|
|||||||
var datItems = datFile.ItemsDB.GetItems();
|
var datItems = datFile.ItemsDB.GetItems();
|
||||||
var machines = datFile.GetMachinesDB();
|
var machines = datFile.GetMachinesDB();
|
||||||
var sources = datFile.ItemsDB.GetSources();
|
var sources = datFile.ItemsDB.GetSources();
|
||||||
var itemMachineMappings = datFile.ItemsDB.GetItemMachineMappings();
|
|
||||||
var itemSourceMappings = datFile.ItemsDB.GetItemSourceMappings();
|
|
||||||
|
|
||||||
// Create mappings from old index to new index
|
// Create mappings from old index to new index
|
||||||
var machineRemapping = new Dictionary<long, long>();
|
var machineRemapping = new Dictionary<long, long>();
|
||||||
@@ -732,8 +726,8 @@ namespace SabreTools.DatTools
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Get the machine and source index for this item
|
// Get the machine and source index for this item
|
||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = datFile.ItemsDB.GetMachineForItem(item.Key).Key;
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = datFile.ItemsDB.GetSourceForItem(item.Key).Key;
|
||||||
|
|
||||||
// If the file is not a Rom, it automatically goes in the "lesser" dat
|
// If the file is not a Rom, it automatically goes in the "lesser" dat
|
||||||
if (item.Value is not Rom rom)
|
if (item.Value is not Rom rom)
|
||||||
@@ -955,8 +949,6 @@ namespace SabreTools.DatTools
|
|||||||
var datItems = datFile.ItemsDB.GetItems();
|
var datItems = datFile.ItemsDB.GetItems();
|
||||||
var machines = datFile.GetMachinesDB();
|
var machines = datFile.GetMachinesDB();
|
||||||
var sources = datFile.ItemsDB.GetSources();
|
var sources = datFile.ItemsDB.GetSources();
|
||||||
var itemMachineMappings = datFile.ItemsDB.GetItemMachineMappings();
|
|
||||||
var itemSourceMappings = datFile.ItemsDB.GetItemSourceMappings();
|
|
||||||
|
|
||||||
// Create mappings from old index to new index
|
// Create mappings from old index to new index
|
||||||
var machineRemapping = new Dictionary<long, long>();
|
var machineRemapping = new Dictionary<long, long>();
|
||||||
@@ -986,8 +978,8 @@ namespace SabreTools.DatTools
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Get the machine and source index for this item
|
// Get the machine and source index for this item
|
||||||
long machineIndex = itemMachineMappings[item.Key];
|
long machineIndex = datFile.ItemsDB.GetMachineForItem(item.Key).Key;
|
||||||
long sourceIndex = itemSourceMappings[item.Key];
|
long sourceIndex = datFile.ItemsDB.GetSourceForItem(item.Key).Key;
|
||||||
|
|
||||||
if (item.Value.GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue<ItemType>() == itemType)
|
if (item.Value.GetStringFieldValue(Models.Metadata.DatItem.TypeKey).AsEnumValue<ItemType>() == itemType)
|
||||||
indexDat.AddItemDB(item.Value, machineRemapping[machineIndex], sourceRemapping[sourceIndex], statsOnly: false);
|
indexDat.AddItemDB(item.Value, machineRemapping[machineIndex], sourceRemapping[sourceIndex], statsOnly: false);
|
||||||
|
|||||||
Reference in New Issue
Block a user