summaryrefslogtreecommitdiff
path: root/fxbarcode/common/BC_CommonBitMatrix.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-07-03 15:57:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-03 15:57:03 +0000
commit1c14ae2fbe1ae95dac3a7f5e60d049d9630aef02 (patch)
tree2d121ae2a0436adce5c54379d1824b427dd03359 /fxbarcode/common/BC_CommonBitMatrix.cpp
parentd77e0ed72f73fb63305d04953ef03e2edab82d34 (diff)
downloadpdfium-1c14ae2fbe1ae95dac3a7f5e60d049d9630aef02.tar.xz
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 <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxbarcode/common/BC_CommonBitMatrix.cpp')
-rw-r--r--fxbarcode/common/BC_CommonBitMatrix.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/fxbarcode/common/BC_CommonBitMatrix.cpp b/fxbarcode/common/BC_CommonBitMatrix.cpp
index 6fe447db6f..a8a6e53bc1 100644
--- a/fxbarcode/common/BC_CommonBitMatrix.cpp
+++ b/fxbarcode/common/BC_CommonBitMatrix.cpp
@@ -22,9 +22,13 @@
#include "fxbarcode/common/BC_CommonBitMatrix.h"
+#include <algorithm>
+#include <iterator>
+
#include "fxbarcode/common/BC_CommonBitArray.h"
#include "fxbarcode/utils.h"
#include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
CBC_CommonBitMatrix::CBC_CommonBitMatrix() {}
@@ -33,8 +37,7 @@ void CBC_CommonBitMatrix::Init(int32_t dimension) {
m_height = dimension;
int32_t rowSize = (m_height + 31) >> 5;
m_rowSize = rowSize;
- m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height);
- memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
+ m_bits = pdfium::Vector2D<int32_t>(m_rowSize, m_height);
}
void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) {
@@ -42,13 +45,10 @@ void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) {
m_height = height;
int32_t rowSize = (width + 31) >> 5;
m_rowSize = rowSize;
- m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height);
- memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
+ m_bits = pdfium::Vector2D<int32_t>(m_rowSize, m_height);
}
-CBC_CommonBitMatrix::~CBC_CommonBitMatrix() {
- FX_Free(m_bits);
-}
+CBC_CommonBitMatrix::~CBC_CommonBitMatrix() = default;
bool CBC_CommonBitMatrix::Get(int32_t x, int32_t y) const {
int32_t offset = y * m_rowSize + (x >> 5);
@@ -70,7 +70,7 @@ void CBC_CommonBitMatrix::Flip(int32_t x, int32_t y) {
}
void CBC_CommonBitMatrix::Clear() {
- memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
+ std::fill(std::begin(m_bits), std::end(m_bits), 0);
}
bool CBC_CommonBitMatrix::SetRegion(int32_t left,