From 1c14ae2fbe1ae95dac3a7f5e60d049d9630aef02 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 3 Jul 2018 15:57:03 +0000 Subject: Avoid explicit allocs in fxbarcode matrix classes. Other cleanups: Remove unused method. Fold Init() into constructor. Return span<> where possible. Change-Id: Ie38d32efb6e63d86ae24e93684903a6dd900810f Reviewed-on: https://pdfium-review.googlesource.com/36810 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp') diff --git a/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp index cdf1e4caf9..582da85078 100644 --- a/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp +++ b/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp @@ -37,7 +37,7 @@ int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1( int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2( CBC_CommonByteMatrix* matrix) { int32_t penalty = 0; - uint8_t* array = matrix->GetArray(); + pdfium::span array = matrix->GetArray(); int32_t width = matrix->GetWidth(); int32_t height = matrix->GetHeight(); for (int32_t y = 0; y < height - 1; y++) { @@ -56,7 +56,7 @@ int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2( int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3( CBC_CommonByteMatrix* matrix) { int32_t penalty = 0; - uint8_t* array = matrix->GetArray(); + pdfium::span array = matrix->GetArray(); int32_t width = matrix->GetWidth(); int32_t height = matrix->GetHeight(); for (int32_t y = 0; y < height; ++y) { @@ -108,14 +108,13 @@ int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3( int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4( CBC_CommonByteMatrix* matrix) { int32_t numDarkCells = 0; - uint8_t* array = matrix->GetArray(); + pdfium::span array = matrix->GetArray(); int32_t width = matrix->GetWidth(); int32_t height = matrix->GetHeight(); for (int32_t y = 0; y < height; ++y) { for (int32_t x = 0; x < width; ++x) { - if (array[y * width + x] == 1) { + if (array[y * width + x] == 1) numDarkCells += 1; - } } } int32_t numTotalCells = matrix->GetHeight() * matrix->GetWidth(); @@ -176,7 +175,7 @@ int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1Internal( int32_t height = matrix->GetHeight(); int32_t iLimit = isHorizontal ? height : width; int32_t jLimit = isHorizontal ? width : height; - uint8_t* array = matrix->GetArray(); + pdfium::span array = matrix->GetArray(); for (int32_t i = 0; i < iLimit; ++i) { for (int32_t j = 0; j < jLimit; ++j) { int32_t bit = isHorizontal ? array[i * width + j] : array[j * width + i]; -- cgit v1.2.3