|
1 | 1 | /*
|
2 | 2 | * Copyright 2006 Milan Digital Audio LLC
|
3 |
| - * Copyright 2009-2023 GrandOrgue contributors (see AUTHORS) |
| 3 | + * Copyright 2009-2024 GrandOrgue contributors (see AUTHORS) |
4 | 4 | * License GPL-2.0 or later
|
5 | 5 | * (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
|
6 | 6 | */
|
|
12 | 12 |
|
13 | 13 | #include "config/GOConfigFileReader.h"
|
14 | 14 |
|
| 15 | +static constexpr unsigned UNUSED_REPORT_LIMIT = 3000; |
| 16 | + |
15 | 17 | GOConfigReaderDB::GOConfigReaderDB(bool case_sensitive)
|
16 | 18 | : m_CaseSensitive(case_sensitive), m_ODF(1000), m_ODF_LC(1000), m_CMB(100) {}
|
17 | 19 |
|
18 | 20 | GOConfigReaderDB::~GOConfigReaderDB() {}
|
19 | 21 |
|
20 | 22 | void GOConfigReaderDB::ReportUnused() {
|
21 |
| - for (GOBoolHashMap::iterator i = m_CMBUsed.begin(); i != m_CMBUsed.end(); |
22 |
| - i++) { |
23 |
| - if (!i->second) { |
24 |
| - wxLogWarning(_("Unused CMB entry '%s'"), i->first.c_str()); |
| 23 | + for (const auto &pair : m_CMBUsed) { |
| 24 | + if (!pair.second) { |
| 25 | + wxLogWarning(_("Unused CMB entry '%s'"), pair.first); |
25 | 26 | }
|
26 | 27 | }
|
| 28 | + |
27 | 29 | bool warn_old = false;
|
28 |
| - for (GOBoolHashMap::iterator i = m_ODFUsed.begin(); i != m_ODFUsed.end(); |
29 |
| - i++) { |
30 |
| - if (!i->second) { |
31 |
| - if (i->first.StartsWith(wxT("_"))) { |
32 |
| - if (!warn_old) { |
| 30 | + unsigned unusedCnt = 0; |
| 31 | + |
| 32 | + for (const auto &pair : m_ODFUsed) { |
| 33 | + if (!pair.second) { |
| 34 | + if (++unusedCnt > UNUSED_REPORT_LIMIT) { |
| 35 | + wxLogWarning( |
| 36 | + _("More than %u unused ODF entries detected"), UNUSED_REPORT_LIMIT); |
| 37 | + break; |
| 38 | + } |
| 39 | + if (pair.first.StartsWith(wxT("_"))) { |
| 40 | + if (!warn_old) |
33 | 41 | wxLogWarning(_("Old GO 0.2 styled setting in ODF"));
|
34 |
| - } |
35 | 42 | warn_old = true;
|
36 |
| - } else { |
37 |
| - wxLogWarning(_("Unused ODF entry '%s'"), i->first.c_str()); |
38 |
| - } |
| 43 | + } else |
| 44 | + wxLogWarning(_("Unused ODF entry '%s'"), pair.first); |
39 | 45 | }
|
40 | 46 | }
|
41 | 47 | }
|
|
0 commit comments