From ea5c7c1d52aacf03a2b989467c145e613b491f46 Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Sat, 20 Feb 2016 15:31:36 +0200 Subject: [PATCH] optimized CameraImageWrapper::getMatrix by removing an extra (uneeded) image copy --- src/CameraImageWrapper.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/CameraImageWrapper.cpp b/src/CameraImageWrapper.cpp index 2b7ebd7..9de102d 100644 --- a/src/CameraImageWrapper.cpp +++ b/src/CameraImageWrapper.cpp @@ -103,10 +103,11 @@ ArrayRef CameraImageWrapper::getMatrix() const { int width = getWidth(); int height = getHeight(); - char* matrix = new char[width*height]; - char* m = matrix; ArrayRef tmpRow(0); + ArrayRef arr(width*height); + + char* m = &arr[0]; for(int y=0; y CameraImageWrapper::getMatrix() const m += width * sizeof(unsigned char); } - ArrayRef arr = ArrayRef(matrix, width*height); - - if (matrix) { - delete matrix; - } - return arr; }