Some code cleanups

This commit is contained in:
Ingo Weyrich
2019-07-27 21:26:00 +02:00
parent de963c54de
commit e748f42427

View File

@@ -661,7 +661,6 @@ void ThumbBrowserBase::arrangeFiles(ThumbBrowserEntryBase* entry)
} }
std::vector<int> colWidths; std::vector<int> colWidths;
std::vector<int> oldColWidths;
for (; numOfCols > 0; --numOfCols) { for (; numOfCols > 0; --numOfCols) {
// compute column widths // compute column widths
@@ -685,8 +684,13 @@ void ThumbBrowserBase::arrangeFiles(ThumbBrowserEntryBase* entry)
} }
} }
bool arrangeAll = true;
// arrange files
int curry = 0;
size_t ct = 0;
if (entry) {
std::vector<int> oldColWidths;
if (oldNumOfCols == numOfCols) { if (oldNumOfCols == numOfCols) {
int oldColsWidth = 0;
for (; oldNumOfCols > 0; --oldNumOfCols) { for (; oldNumOfCols > 0; --oldNumOfCols) {
// compute old column widths // compute old column widths
oldColWidths.assign(oldNumOfCols, 0); oldColWidths.assign(oldNumOfCols, 0);
@@ -700,17 +704,13 @@ void ThumbBrowserBase::arrangeFiles(ThumbBrowserEntryBase* entry)
++j; ++j;
} }
} }
// if not wider than the space available, arrange it and we are ready if (oldNumOfCols == 1 || std::accumulate(oldColWidths.begin(), oldColWidths.end(), 0) < availWidth) {
oldColsWidth = std::accumulate(oldColWidths.begin(), oldColWidths.end(), 0);
if (oldNumOfCols == 1 || oldColsWidth < availWidth) {
break; break;
} }
} }
} }
bool arrangeAll = true; if (oldNumOfCols == numOfCols) {
if (entry && oldNumOfCols == numOfCols && oldColWidths.size() > 0) {
arrangeAll = false; arrangeAll = false;
for (int i = 0; i < numOfCols; ++i) { for (int i = 0; i < numOfCols; ++i) {
if(colWidths[i] != oldColWidths[i]) { if(colWidths[i] != oldColWidths[i]) {
@@ -719,11 +719,7 @@ void ThumbBrowserBase::arrangeFiles(ThumbBrowserEntryBase* entry)
} }
} }
} }
if (!arrangeAll) {
// arrange files
int curry = 0;
size_t ct = 0;
if (entry && !arrangeAll) {
int i = 0; int i = 0;
// Find currently added entry // Find currently added entry
for (; ct < fd.size() && fd[ct] != entry; i += !fd[ct]->filtered, ++ct) { for (; ct < fd.size() && fd[ct] != entry; i += !fd[ct]->filtered, ++ct) {
@@ -752,6 +748,7 @@ void ThumbBrowserBase::arrangeFiles(ThumbBrowserEntryBase* entry)
curry += rowHeight; curry += rowHeight;
} }
} }
}
// arrange remaining entries, if any, that's the most expensive part // arrange remaining entries, if any, that's the most expensive part
for (; ct < fd.size();) { for (; ct < fd.size();) {