Fix compiler warnings in TWERD::MergeBlobs and optimize code

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-10-09 11:15:47 +02:00
parent 0cdcd0f02b
commit 4c36e2e29a
2 changed files with 8 additions and 5 deletions

View File

@ -871,12 +871,15 @@ TBOX TWERD::bounding_box() const {
// Merges the blobs from start to end, not including end, and deletes
// the blobs between start and end.
void TWERD::MergeBlobs(int start, int end) {
if (start >= blobs.size() - 1) {
void TWERD::MergeBlobs(unsigned start, unsigned end) {
if (end > blobs.size()) {
end = blobs.size();
}
if (start >= end) {
return; // Nothing to do.
}
TESSLINE *outline = blobs[start]->outlines;
for (int i = start + 1; i < end && i < blobs.size(); ++i) {
for (auto i = start + 1; i < end; ++i) {
TBLOB *next_blob = blobs[i];
// Take the outlines from the next blob.
if (outline == nullptr) {
@ -895,7 +898,7 @@ void TWERD::MergeBlobs(int start, int end) {
}
// Remove dead blobs from the vector.
// TODO: optimize.
for (int i = start + 1; i < end && start + 1 < blobs.size(); ++i) {
for (auto i = start + 1; i < end && start + 1 < blobs.size(); ++i) {
blobs.erase(blobs.begin() + start + 1);
}
}

View File

@ -453,7 +453,7 @@ struct TWERD {
// Merges the blobs from start to end, not including end, and deletes
// the blobs between start and end.
void MergeBlobs(int start, int end);
void MergeBlobs(unsigned start, unsigned end);
#ifndef GRAPHICS_DISABLED
void plot(ScrollView *window);