From 106166f3cc77eaa440f128a50ce9c8187209128e Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Tue, 30 Apr 2013 21:19:32 -0400 Subject: [PATCH] Make this O(n / 2). Or something like that. This is designed to be transplantable. --- src/UnlockManager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/UnlockManager.cpp b/src/UnlockManager.cpp index b12331570b..6e0a856801 100644 --- a/src/UnlockManager.cpp +++ b/src/UnlockManager.cpp @@ -564,10 +564,18 @@ void UnlockManager::Load() // Make sure that we don't have duplicate unlock IDs. This can cause problems // with UnlockCelebrate and with codes. - FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue ) - FOREACH_CONST( UnlockEntry, m_UnlockEntries, ue2 ) - if( ue != ue2 ) - ASSERT_M( ue->m_sEntryID != ue2->m_sEntryID, ssprintf("duplicate unlock entry id %s",ue->m_sEntryID.c_str()) ); + unsigned size = m_UnlockEntries.size(); + for (unsigned i = 0; i < size - 1; ++i) + { + UnlockEntry const &ue1 = m_UnlockEntries[i]; + for (unsigned j = i + 1; j < size; ++j) + { + UnlockEntry const &ue2 = m_UnlockEntries[j]; + // at this point, these two are definitely different. Assert. + ASSERT_M( ue1.m_sEntryID != ue2.m_sEntryID, ssprintf("duplicate unlock entry id %s", ue1.m_sEntryID.c_str())); + + } + } for (UnlockEntry &e : m_UnlockEntries) {