@Thunderbrd a valuable patch before the eventual release:
Quoting
billw on the discord channel:
He provided his save to evaluate in the link above.
Two hours later...
He patched the search method of finding in a std::set from using std::find on a std::set to using std::set::find function instead.
https://cdn.discordapp.com/attachme...9/597902376963407888/StdSetOptimization.patch
In case you can't download this patch, create a text file ending in .patch and use TortoiseSVN function to apply the patch:
Code:
Index: Sources/CvSelectionGroup.cpp
===================================================================
--- Sources/CvSelectionGroup.cpp (revision 10658)
+++ Sources/CvSelectionGroup.cpp (working copy)
@@ -8705,7 +8705,7 @@
while (pUnitNode != NULL)
{
- if (movedUnitIds.empty() || std::find(movedUnitIds.begin(), movedUnitIds.end(), pUnitNode->m_data.iID) == movedUnitIds.end())
+ if (movedUnitIds.empty() || movedUnitIds.find(pUnitNode->m_data.iID) == movedUnitIds.end())
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
Index: Sources/CvUnit.cpp
===================================================================
--- Sources/CvUnit.cpp (revision 10658)
+++ Sources/CvUnit.cpp (working copy)
@@ -9049,7 +9049,7 @@
while (pUnitNode != NULL)
{
- if (movedUnitIds.empty() || std::find(movedUnitIds.begin(), movedUnitIds.end(), pUnitNode->m_data.iID) == movedUnitIds.end())
+ if (movedUnitIds.empty() || movedUnitIds.find(pUnitNode->m_data.iID) == movedUnitIds.end())
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
@@ -19462,7 +19462,7 @@
while (pUnitNode != NULL)
{
- if (movedUnitIds.empty() || std::find(movedUnitIds.begin(), movedUnitIds.end(), pUnitNode->m_data.iID) == movedUnitIds.end())
+ if (movedUnitIds.empty() || movedUnitIds.find(pUnitNode->m_data.iID) == movedUnitIds.end())
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
I tested his patch too. I can definitely finish his turn now, in 6 minutes on my computer.
My comment:
Using std::set::find reduces the search time because of the internal structure of a std::set.
While std::find performs a linear search to find the element, the std::set::find function performs a red-black tree search so it's much more efficient.
If the needle does not exist in a set, doing std::find has to traverse the whole list, while doing std::set::find moves through only a certain branch of the tree before the search ends.
This has more complication when the set is large enough.