Skip to content

Commit

Permalink
more optimisation, move ops for ImgIdx
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray committed Jun 16, 2018
1 parent f43b8a1 commit a43a693
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ImgIdx.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ class ImgIdx
ImgIdx::Idx _idx;
};

using ImgIdxs = std::list<ImgIdx*>;
using ImgIdxs = std::list<ImgIdx>;

#endif
16 changes: 6 additions & 10 deletions src/imgcat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ struct _Task
}

// mtx/conds are not movable
_Task(_Task&&) = delete
_Task(_Task&&) = delete;
_Task& operator=(const _Task&) = delete;
_Task& operator=(const _Task&&) = delete;

Expand Down Expand Up @@ -485,7 +485,7 @@ int main(int argc, char **argv)
if ( dir[dirlen-1] == '/' ) {
dir[dirlen-1] = (char)NULL;
}
idxs.push_back(new ImgIdx(dir));
idxs.emplace_back(ImgIdx(dir));

try
{
Expand All @@ -506,7 +506,7 @@ int main(int argc, char **argv)
try
{
const Img img = exifparser.parse(i.filename.c_str(), i.st, thumbpath);
(*idxs.back())[img.key].push_back(img.data);
idxs.back()[img.key].push_back(img.data);
}
catch (const std::invalid_argument& ex)
{
Expand All @@ -520,7 +520,7 @@ int main(int argc, char **argv)
try
{
const Img img = avfmtparser.parse(i.filename.c_str(), i.st, thumbpath);
(*idxs.back())[img.key].push_back(img.data);
idxs.back()[img.key].push_back(img.data);
}
catch (const std::exception& ex)
{
Expand Down Expand Up @@ -553,9 +553,8 @@ int main(int argc, char **argv)
ImgHtml::Payloads htmlpayloads;

std::cout << "generating thumbnail previews.." << std::endl;
for (const auto& i : idxs)
for (auto& idx : idxs)
{
ImgIdx& idx = *i;
std::cout << " working on [" << std::setw(3) << idx.size() << "] " << idx.id << " " << std::flush;

if (idx.empty()) {
Expand Down Expand Up @@ -583,7 +582,7 @@ int main(int argc, char **argv)
}


htmlpayloads.push_back(ImgHtml::Payload(idx));
htmlpayloads.emplace_back(ImgHtml::Payload(idx));

for (auto& t : tasks)
{
Expand Down Expand Up @@ -653,9 +652,6 @@ int main(int argc, char **argv)
const std::chrono::duration<double> elapsed = now - start;
std::cout << "completed in " << elapsed.count() << " secs" << std::endl;

for (auto i : idxs) {
delete i;
}
idxs.clear();
delete htmlgen;

Expand Down

0 comments on commit a43a693

Please sign in to comment.