Skip to content

Commit

Permalink
Use STL container for imagelist and loadimageids (#729)
Browse files Browse the repository at this point in the history
* Use STL container for imagelist and loadimageids

* Use range-based loops on STL container

* Separate identifiers
  • Loading branch information
tobiolo authored Oct 30, 2024
1 parent 149da3a commit e2ecaa2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ struct System {
Evaluator ev;
wxString clipboardcopy;
unique_ptr<Cell> cellclipboard;
Vector<Image *> imagelist;
Vector<int> loadimageids;
std::vector<Image *> imagelist;
std::vector<int> loadimageids;
uchar versionlastloaded {0};
wxLongLong fakelasteditonload;
wxPen pen_tinytext {wxColour(0x808080ul)};
Expand Down Expand Up @@ -269,7 +269,7 @@ struct System {
int zoomlevel = versionlastloaded >= 23 ? dis.Read8() : 0;
fakelasteditonload = wxDateTime::Now().GetValue();

loadimageids.setsize(0);
loadimageids.clear();

for (;;) {
fis.Read(buf, 1);
Expand Down Expand Up @@ -319,7 +319,7 @@ struct System {
}
if (!fis.IsOk()) image_data.clear();

loadimageids.push() = AddImageToList(sc, std::move(image_data), iti);
loadimageids.push_back(AddImageToList(sc, std::move(image_data), iti));
break;
}

Expand Down Expand Up @@ -370,12 +370,12 @@ struct System {
doc->RefreshImageRefCount(false);
{
ThreadPool pool(std::thread::hardware_concurrency());
loopv(i, sys->imagelist) {
for (auto *image : sys->imagelist) {
pool.enqueue(
[](Image *img) {
if (img->trefc) img->Display();
},
sys->imagelist[i]);
image);
}
} // wait until all tasks are finished

Expand Down Expand Up @@ -620,7 +620,7 @@ struct System {
loopv(i, imagelist) {
if (imagelist[i]->hash == hash) return i;
}
imagelist.push() = new Image(hash, sc, std::move(idv), iti);
imagelist.push_back(new Image(hash, sc, std::move(idv), iti));
return imagelist.size() - 1;
}

Expand Down

0 comments on commit e2ecaa2

Please sign in to comment.