Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Commit

Permalink
Repeated calls to IsRecordWinning() is now faster / more efficient
Browse files Browse the repository at this point in the history
  Results are cached per FormID/EditorID, so records with many conflicts benefit the most
GetRecordHistory, GetRecordConflicts are marginally faster
  Both no longer require std::pair creation / destruction
  GetRecordConflicts results are now sorted in reverse, and no longer iterated in reverse
GetNumIdenticalToMasterRecords/GetIdenticalToMasterRecords now try to use less memory when running
flags no longer require cleaning before use
  Added separate flag field for CBash internal use
  Pointer tricks no longer used on Parent / recData fields to store flags
  Memory usage up ~5MB on loading Oblivion.esm
  Various accessors/setters removed or simplified
ObTest updated
ModFile saving updated
  ModFiles are no longer closed on save
  ModFiles now save to "*.new.%Y_%m_%d_%H_%M_%S" instead of a random temporary name such as "xYS24I"
    If renaming the temporary file fails, users can now see an understandable filename
  When a collection is closed, the temp name is renamed to the original filename
  This allows the original filemapping to remain open throughout the lifetime of a collection
    Strings no longer return garbage / segfault if accessed after the mod is saved
    ModFiles are no longer fully read into memory on save if CloseCollection is false

cint
  Removed unused GetExtendedConflicts parameter from ConflictDetails
  HasRecord, LookupRecord now requires a FormID() parameter (no longer accepts a tuple or raw hex)
  • Loading branch information
waruddar committed Sep 16, 2011
1 parent a081453 commit 9549959
Show file tree
Hide file tree
Showing 158 changed files with 861 additions and 852 deletions.
Binary file modified CBash.suo
Binary file not shown.
56 changes: 49 additions & 7 deletions CBash/CBash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,24 @@ CPPDLLEXTERN SINT32 DeleteCollection(Collection *CollectionID)
try
{
//ValidatePointer(CollectionID);
for(UINT32 p = 0; p < Collections.size(); ++p)
for(UINT32 ListIndex = 0; ListIndex < Collections.size(); ++ListIndex)
{
if(Collections[p] == CollectionID)
if(Collections[ListIndex] == CollectionID)
{
delete Collections[p];
Collections[p] = NULL;
for(UINT32 ListX2Index = 0; ListX2Index < CollectionID->ModFiles.size(); ++ListX2Index)
CollectionID->ModFiles[ListX2Index]->Close();
for(UINT32 ListX2Index = 0; ListX2Index < CollectionID->closing_ops.size(); ++ListX2Index)
{
CollectionID->closing_ops[ListX2Index]->perform();
delete CollectionID->closing_ops[ListX2Index];
}
delete CollectionID;
Collections[ListIndex] = NULL;
}
}
for(UINT32 p = 0; p < Collections.size(); ++p)
for(UINT32 ListIndex = 0; ListIndex < Collections.size(); ++ListIndex)
{
if(Collections[p] != NULL)
if(Collections[ListIndex] != NULL)
return 0;
}
Collections.clear();
Expand Down Expand Up @@ -1266,6 +1273,28 @@ CPPDLLEXTERN SINT32 DeleteRecord(Record *RecordID)
//ValidatePointer(CollectionID);
//ValidatePointer(ModID);
RecordDeindexer deindexer(RecordID);

if(RecordID->IsWinningDetermined() && (RecordID->IsWinning() || RecordID->IsExtendedWinning()))
{
FORMID FormID = RecordID->formID;
STRING EditorID = RecordID->GetEditorIDKey();
bool IsKeyedByEditorID = RecordID->IsKeyedByEditorID();
Collection *CollectionID = RecordID->GetParentMod()->Parent;
if(RecordID->GetParentMod()->DeleteRecord(RecordID, deindexer))
{
//Update the IsWinning flags for all related records
ModFile *WinningModfile = NULL;
Record *WinningRecord = NULL;

if(IsKeyedByEditorID)
CollectionID->LookupWinningRecord(EditorID, WinningModfile, WinningRecord, true);
else
CollectionID->LookupWinningRecord(FormID, WinningModfile, WinningRecord, true);
return 1;
}
return 0;
}

return RecordID->GetParentMod()->DeleteRecord(RecordID, deindexer);
}
catch(std::exception &ex)
Expand Down Expand Up @@ -1372,7 +1401,20 @@ CPPDLLEXTERN SINT32 IsRecordWinning(Record *RecordID, const bool GetExtendedConf
{
//ValidatePointer(CollectionID);
//ValidatePointer(ModID);
return RecordID->GetParentMod()->Parent->IsRecordWinning(RecordID, GetExtendedConflicts);
if(!RecordID->IsWinningDetermined())
{
ModFile *WinningModfile = NULL;
Record *WinningRecord = NULL;
if(RecordID->IsKeyedByEditorID())
RecordID->GetParentMod()->Parent->LookupWinningRecord(RecordID->GetEditorIDKey(), WinningModfile, WinningRecord, true);
else
RecordID->GetParentMod()->Parent->LookupWinningRecord(RecordID->formID, WinningModfile, WinningRecord, true);
}
if(GetExtendedConflicts)
return RecordID->IsExtendedWinning();
else if(RecordID->GetParentMod()->Flags.IsExtendedConflicts)
return false;
return RecordID->IsWinning();
}
catch(std::exception &ex)
{
Expand Down
Loading

0 comments on commit 9549959

Please sign in to comment.