Prefer addall instead of iteration for performance

pull/17248/head
Nicolas Roduit 5 years ago committed by Alexander Smorkalov
parent c8689d9d0a
commit 400a781ebf
  1. 18
      modules/java/generator/src/java/org/opencv/utils/Converters.java

@ -519,8 +519,7 @@ public class Converters {
Mat res; Mat res;
int lCount = (pts != null) ? pts.size() : 0; int lCount = (pts != null) ? pts.size() : 0;
if (lCount > 0) { if (lCount > 0) {
for (MatOfPoint vpt : pts) mats.addAll(pts);
mats.add(vpt);
res = vector_Mat_to_Mat(mats); res = vector_Mat_to_Mat(mats);
} else { } else {
res = new Mat(); res = new Mat();
@ -568,8 +567,7 @@ public class Converters {
Mat res; Mat res;
int lCount = (pts != null) ? pts.size() : 0; int lCount = (pts != null) ? pts.size() : 0;
if (lCount > 0) { if (lCount > 0) {
for (MatOfPoint2f vpt : pts) mats.addAll(pts);
mats.add(vpt);
res = vector_Mat_to_Mat(mats); res = vector_Mat_to_Mat(mats);
} else { } else {
res = new Mat(); res = new Mat();
@ -600,8 +598,7 @@ public class Converters {
Mat res; Mat res;
int lCount = (pts != null) ? pts.size() : 0; int lCount = (pts != null) ? pts.size() : 0;
if (lCount > 0) { if (lCount > 0) {
for (MatOfPoint3f vpt : pts) mats.addAll(pts);
mats.add(vpt);
res = vector_Mat_to_Mat(mats); res = vector_Mat_to_Mat(mats);
} else { } else {
res = new Mat(); res = new Mat();
@ -614,8 +611,7 @@ public class Converters {
Mat res; Mat res;
int lCount = (kps != null) ? kps.size() : 0; int lCount = (kps != null) ? kps.size() : 0;
if (lCount > 0) { if (lCount > 0) {
for (MatOfKeyPoint vkp : kps) mats.addAll(kps);
mats.add(vkp);
res = vector_Mat_to_Mat(mats); res = vector_Mat_to_Mat(mats);
} else { } else {
res = new Mat(); res = new Mat();
@ -714,8 +710,7 @@ public class Converters {
Mat res; Mat res;
int lCount = (lvdm != null) ? lvdm.size() : 0; int lCount = (lvdm != null) ? lvdm.size() : 0;
if (lCount > 0) { if (lCount > 0) {
for (MatOfDMatch vdm : lvdm) mats.addAll(lvdm);
mats.add(vdm);
res = vector_Mat_to_Mat(mats); res = vector_Mat_to_Mat(mats);
} else { } else {
res = new Mat(); res = new Mat();
@ -746,8 +741,7 @@ public class Converters {
Mat res; Mat res;
int lCount = (lvb != null) ? lvb.size() : 0; int lCount = (lvb != null) ? lvb.size() : 0;
if (lCount > 0) { if (lCount > 0) {
for (MatOfByte vb : lvb) mats.addAll(lvb);
mats.add(vb);
res = vector_Mat_to_Mat(mats); res = vector_Mat_to_Mat(mats);
} else { } else {
res = new Mat(); res = new Mat();

Loading…
Cancel
Save