summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl12rs <gabriel.cortesi@outlook.com>2018-08-14 11:35:20 -0500
committerLostDragonist <lost.dragonist@gmail.com>2018-12-12 20:16:50 -0600
commit49159de5d7084bf1ac159e3e37e2b406cdd87dbf (patch)
treeeee325c67516bd360f672683daa13d494f8b19da
parent75a663941d5a58b9676e2eb99a2a288abc19a359 (diff)
Improved refresh performance by replacing std::transform() with CharLowerBuffer().
Fixed padding to four spaces and removed references to FLAG_ARCHIVE_LOOSE_CONFLICTS_MIXED that isn't used.
-rw-r--r--src/modflagicondelegate.cpp32
-rw-r--r--src/modflagicondelegate.h2
-rw-r--r--src/modinfo.h1
-rw-r--r--src/modlist.cpp1
-rw-r--r--src/modlistsortproxy.cpp1
-rw-r--r--src/shared/util.cpp12
6 files changed, 28 insertions, 21 deletions
diff --git a/src/modflagicondelegate.cpp b/src/modflagicondelegate.cpp
index a0a0a86d..48d71313 100644
--- a/src/modflagicondelegate.cpp
+++ b/src/modflagicondelegate.cpp
@@ -7,8 +7,7 @@ ModInfo::EFlag ModFlagIconDelegate::m_ConflictFlags[4] = { ModInfo::FLAG_CONFLIC
, ModInfo::FLAG_CONFLICT_OVERWRITTEN
, ModInfo::FLAG_CONFLICT_REDUNDANT };
-ModInfo::EFlag ModFlagIconDelegate::m_ArchiveLooseConflictFlags[3] = { ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_MIXED
- , ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE
+ModInfo::EFlag ModFlagIconDelegate::m_ArchiveLooseConflictFlags[2] = { ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE
, ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN };
ModInfo::EFlag ModFlagIconDelegate::m_ArchiveConflictFlags[3] = { ModInfo::FLAG_ARCHIVE_CONFLICT_MIXED
@@ -39,26 +38,33 @@ QList<QString> ModFlagIconDelegate::getIcons(const QModelIndex &index) const {
}
}
- { // insert archive vs loose conflicts second
- int pad = 2;
+ { // insert loose vs archive overwrite second
+ auto iter = std::find(flags.begin(), flags.end(),
+ ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE);
+ if (iter != flags.end()) {
+ result.append(getFlagIcon(*iter));
+ flags.erase(iter);
+ }
+ else {
+ result.append(QString());
+ }
+ }
+
+ { // insert loose vs archive overwritten third
auto iter = std::find_first_of(flags.begin(), flags.end(),
- m_ArchiveLooseConflictFlags, m_ArchiveLooseConflictFlags + 4);
- while (iter != flags.end()) {
+ m_ArchiveLooseConflictFlags + 1, m_ArchiveLooseConflictFlags + 2);
+ if (iter != flags.end()) {
result.append(getFlagIcon(*iter));
flags.erase(iter);
- pad--;
- iter = std::find_first_of(flags.begin(), flags.end(),
- m_ArchiveLooseConflictFlags, m_ArchiveLooseConflictFlags + 4);
}
- while (pad > 0) {
+ else {
result.append(QString());
- pad--;
}
}
{ // insert archive conflicts last
auto iter = std::find_first_of(flags.begin(), flags.end(),
- m_ArchiveConflictFlags, m_ArchiveConflictFlags + 4);
+ m_ArchiveConflictFlags, m_ArchiveConflictFlags + 3);
if (iter != flags.end()) {
result.append(getFlagIcon(*iter));
flags.erase(iter);
@@ -87,7 +93,7 @@ QString ModFlagIconDelegate::getFlagIcon(ModInfo::EFlag flag) const
case ModInfo::FLAG_CONFLICT_OVERWRITTEN: return ":/MO/gui/emblem_conflict_overwritten";
case ModInfo::FLAG_CONFLICT_MIXED: return ":/MO/gui/emblem_conflict_mixed";
case ModInfo::FLAG_CONFLICT_REDUNDANT: return ":MO/gui/emblem_conflict_redundant";
- case ModInfo::FLAG_ALTERNATE_GAME: return ":MO/gui/alternate_game";
+ case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_MIXED: return ":/MO/gui/archive_loose_conflict_mixed";
case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE: return ":/MO/gui/archive_loose_conflict_overwrite";
case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN: return ":/MO/gui/archive_loose_conflict_overwritten";
case ModInfo::FLAG_ARCHIVE_CONFLICT_MIXED: return ":/MO/gui/archive_conflict_mixed";
diff --git a/src/modflagicondelegate.h b/src/modflagicondelegate.h
index 7324d516..0f257c7d 100644
--- a/src/modflagicondelegate.h
+++ b/src/modflagicondelegate.h
@@ -15,7 +15,7 @@ private:
QString getFlagIcon(ModInfo::EFlag flag) const;
private:
static ModInfo::EFlag m_ConflictFlags[4];
- static ModInfo::EFlag m_ArchiveLooseConflictFlags[3];
+ static ModInfo::EFlag m_ArchiveLooseConflictFlags[2];
static ModInfo::EFlag m_ArchiveConflictFlags[3];
};
diff --git a/src/modinfo.h b/src/modinfo.h
index 99ce35b5..00859209 100644
--- a/src/modinfo.h
+++ b/src/modinfo.h
@@ -74,7 +74,6 @@ public:
FLAG_CONFLICT_REDUNDANT,
FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE,
FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN,
- FLAG_ARCHIVE_LOOSE_CONFLICT_MIXED,
FLAG_ARCHIVE_CONFLICT_OVERWRITE,
FLAG_ARCHIVE_CONFLICT_OVERWRITTEN,
FLAG_ARCHIVE_CONFLICT_MIXED,
diff --git a/src/modlist.cpp b/src/modlist.cpp
index fd6da43b..8c070667 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -163,7 +163,6 @@ QString ModList::getFlagText(ModInfo::EFlag flag, ModInfo::Ptr modInfo) const
case ModInfo::FLAG_CONFLICT_OVERWRITTEN: return tr("Overwritten loose files");
case ModInfo::FLAG_CONFLICT_MIXED: return tr("Loose files Overwrites & Overwritten");
case ModInfo::FLAG_CONFLICT_REDUNDANT: return tr("Redundant");
- case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_MIXED: return tr("Contains archive files overwritten by loose files and loose files overwriting an archive");
case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE: return tr("Overwrites an archive with loose files");
case ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN: return tr("Archive is overwritten by loose files");
case ModInfo::FLAG_ARCHIVE_CONFLICT_OVERWRITE: return tr("Overwrites another archive file");
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index 88a073e0..8cf4bb9c 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -244,7 +244,6 @@ bool ModListSortProxy::hasConflictFlag(const std::vector<ModInfo::EFlag> &flags)
(flag == ModInfo::FLAG_ARCHIVE_CONFLICT_OVERWRITE) ||
(flag == ModInfo::FLAG_ARCHIVE_CONFLICT_OVERWRITTEN) ||
(flag == ModInfo::FLAG_ARCHIVE_CONFLICT_MIXED) ||
- (flag == ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_MIXED) ||
(flag == ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITE) ||
(flag == ModInfo::FLAG_ARCHIVE_LOOSE_CONFLICT_OVERWRITTEN)) {
return true;
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index 102565f5..b65ed071 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -108,27 +108,31 @@ static auto locToLower = [] (char in) -> char {
std::string &ToLower(std::string &text)
{
- std::transform(text.begin(), text.end(), text.begin(), locToLower);
+ //std::transform(text.begin(), text.end(), text.begin(), locToLower);
+ CharLowerBuffA(const_cast<CHAR *>(text.c_str()), static_cast<DWORD>(text.size()));
return text;
}
std::string ToLower(const std::string &text)
{
std::string result(text);
- std::transform(result.begin(), result.end(), result.begin(), locToLower);
+ //std::transform(result.begin(), result.end(), result.begin(), locToLower);
+ CharLowerBuffA(const_cast<CHAR *>(result.c_str()), static_cast<DWORD>(result.size()));
return result;
}
std::wstring &ToLower(std::wstring &text)
{
- std::transform(text.begin(), text.end(), text.begin(), locToLowerW);
+ //std::transform(text.begin(), text.end(), text.begin(), locToLowerW);
+ CharLowerBuffW(const_cast<WCHAR *>(text.c_str()), static_cast<DWORD>(text.size()));
return text;
}
std::wstring ToLower(const std::wstring &text)
{
std::wstring result(text);
- std::transform(result.begin(), result.end(), result.begin(), locToLowerW);
+ //std::transform(result.begin(), result.end(), result.begin(), locToLowerW);
+ CharLowerBuffW(const_cast<WCHAR *>(result.c_str()), static_cast<DWORD>(result.size()));
return result;
}