summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-29 11:24:14 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-29 11:24:15 -0700
commitd5d07dcf59ddc6439f73382c6e0b9e6d1851000d (patch)
tree3430639a1c286570a60e946e1b850aeeedaaa05a /xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
parentcd1e9ff4f432cbc29ed279e6891fb7ddc2ea3734 (diff)
downloadpdfium-d5d07dcf59ddc6439f73382c6e0b9e6d1851000d.tar.xz
Replace CFX_PtrArray with typesafe CFX_ArrayTemplate, part 8
This also removes another hand-written bubblesort in favor of the std::sort() STL function. Review-Url: https://codereview.chromium.org/1937513002
Diffstat (limited to 'xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp')
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
index c70f8b1fc9..6b7680d1a8 100644
--- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
@@ -33,10 +33,10 @@ CBC_DataMatrixDataBlock::CBC_DataMatrixDataBlock(int32_t numDataCodewords,
m_codewords.Copy(*codewords);
m_numDataCodewords = numDataCodewords;
}
-CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
- CFX_ByteArray* rawCodewords,
- CBC_DataMatrixVersion* version,
- int32_t& e) {
+CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>*
+CBC_DataMatrixDataBlock::GetDataBlocks(CFX_ByteArray* rawCodewords,
+ CBC_DataMatrixVersion* version,
+ int32_t& e) {
ECBlocks* ecBlocks = version->GetECBlocks();
int32_t totalBlocks = 0;
const CFX_ArrayTemplate<ECB*>& ecBlockArray = ecBlocks->GetECBlocks();
@@ -44,7 +44,8 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
for (i = 0; i < ecBlockArray.GetSize(); i++) {
totalBlocks += ecBlockArray[i]->GetCount();
}
- std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray());
+ std::unique_ptr<CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>> result(
+ new CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>());
result->SetSize(totalBlocks);
int32_t numResultBlocks = 0;
int32_t j;
@@ -59,8 +60,7 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
codewords.SetSize(0);
}
}
- int32_t longerBlocksTotalCodewords =
- ((CBC_DataMatrixDataBlock*)(*result)[0])->GetCodewords()->GetSize();
+ int32_t longerBlocksTotalCodewords = (*result)[0]->GetCodewords()->GetSize();
int32_t longerBlocksNumDataCodewords =
longerBlocksTotalCodewords - ecBlocks->GetECCodewords();
int32_t shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1;
@@ -69,10 +69,8 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
int32_t j;
for (j = 0; j < numResultBlocks; j++) {
if (rawCodewordsOffset < rawCodewords->GetSize()) {
- ((CBC_DataMatrixDataBlock*)(*result)[j])
- ->GetCodewords()
- ->
- operator[](i) = (*rawCodewords)[rawCodewordsOffset++];
+ (*result)[j]->GetCodewords()->operator[](i) =
+ (*rawCodewords)[rawCodewordsOffset++];
}
}
}
@@ -80,24 +78,19 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
int32_t numLongerBlocks = specialVersion ? 8 : numResultBlocks;
for (j = 0; j < numLongerBlocks; j++) {
if (rawCodewordsOffset < rawCodewords->GetSize()) {
- ((CBC_DataMatrixDataBlock*)(*result)[j])
- ->GetCodewords()
- ->
- operator[](longerBlocksNumDataCodewords - 1) =
+ (*result)[j]->GetCodewords()->operator[](longerBlocksNumDataCodewords -
+ 1) =
(*rawCodewords)[rawCodewordsOffset++];
}
}
- int32_t max =
- ((CBC_DataMatrixDataBlock*)(*result)[0])->GetCodewords()->GetSize();
+ int32_t max = (*result)[0]->GetCodewords()->GetSize();
for (i = longerBlocksNumDataCodewords; i < max; i++) {
int32_t j;
for (j = 0; j < numResultBlocks; j++) {
int32_t iOffset = specialVersion && j > 7 ? i - 1 : i;
if (rawCodewordsOffset < rawCodewords->GetSize()) {
- ((CBC_DataMatrixDataBlock*)(*result)[j])
- ->GetCodewords()
- ->
- operator[](iOffset) = (*rawCodewords)[rawCodewordsOffset++];
+ (*result)[j]->GetCodewords()->operator[](iOffset) =
+ (*rawCodewords)[rawCodewordsOffset++];
}
}
}