Skip to content

Commit

Permalink
use size_t over int
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Sep 7, 2023
1 parent 26a93d1 commit 4a927bb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/sf_packing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ cpp11::doubles make_point(cpp11::doubles &x, cpp11::doubles &y, std::vector< std
}
cpp11::writable::list make_path(cpp11::doubles &x, cpp11::doubles &y, std::vector< std::vector<int> > &start) {
cpp11::writable::list res;
int i, j;
for (i = 0; i < start.size() - 1; ++i) {
for (j = 0; j < start[i].size(); ++j) {
for (size_t i = 0; i < start.size() - 1; ++i) {
for (size_t j = 0; j < start[i].size(); ++j) {
int first = start[i][j];
int last = j == start[i].size() - 1 ? start[i + 1][0] : start[i][j + 1] - 1;
cpp11::writable::doubles_matrix<> path(last - first, 2);
Expand All @@ -149,15 +148,14 @@ cpp11::writable::list make_path(cpp11::doubles &x, cpp11::doubles &y, std::vecto
cpp11::writable::list make_polygon(cpp11::doubles &x, cpp11::doubles &y, std::vector< std::vector<int> > &start) {
cpp11::writable::list res;

int i, j, k;
for (i = 0; i < start.size() - 1; ++i) {
for (size_t i = 0; i < start.size() - 1; ++i) {
cpp11::writable::list poly;
for (j = 0; j < start[i].size(); ++j) {
for (size_t j = 0; j < start[i].size(); ++j) {
int first = start[i][j];
int last = j == start[i].size() - 1 ? start[i + 1][0] : start[i][j + 1] - 1;
cpp11::writable::doubles_matrix<> polygon(last - first + 1, 2);
int row = 0;
for (k = first; k < last; ++k) {
for (int k = first; k < last; ++k) {
polygon(row, 0) = x[k];
polygon(row, 1) = y[k];
row++;
Expand Down

0 comments on commit 4a927bb

Please sign in to comment.