From fad69219ad80545e9dac6e62a1d0259317d444095d70a606c60c582dceeedf2b Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Mon, 11 Aug 2025 02:30:11 -0400 Subject: [PATCH] A few more `SimpleVector` changes. --- dw/hyphenator.cc | 11 +++++------ dw/table.cc | 20 +++++++++----------- dw/table.hh | 6 +++--- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/dw/hyphenator.cc b/dw/hyphenator.cc index f707d37..fd1553c 100644 --- a/dw/hyphenator.cc +++ b/dw/hyphenator.cc @@ -140,7 +140,7 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s) // Convert the a pattern like 'a1bc3d4' into a string of chars 'abcd' // and a list of points [ 0, 1, 0, 3, 4 ]. std::string chars; - SimpleVector points (1); + std::vector< char > points; // TODO numbers consisting of multiple digits? // TODO Encoding: This implementation works exactly like the Python @@ -148,8 +148,7 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s) int numChars = 0; for (int i = 0; s[i]; i++) { if (s[i] >= '0' && s[i] <= '9') { - points.setSize(numChars + 1, '0'); - points.set(numChars, s[i]); + points.push_back( s[ i ] ); } else { numChars++; chars+= s[i]; @@ -157,8 +156,8 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s) } chars[numChars] = 0; - points.setSize(numChars + 2, '0'); - points.set(numChars + 1, '\0'); + points.resize( numChars + 2, '0' ); + points.at( numChars + 1 )= '\0'; // Insert the pattern into the tree. Each character finds a dict // another level down in the tree, and leaf nodes have the list of @@ -166,7 +165,7 @@ void Hyphenator::insertPattern (TrieBuilder *trieBuilder, char *s) //printf("insertPattern %s\n", chars); - trieBuilder->insert (chars.c_str(), points.getArray ()); + trieBuilder->insert (chars.c_str(), points.data()); } void Hyphenator::insertException (char *s) diff --git a/dw/table.cc b/dw/table.cc index 85e5d25..acc4732 100644 --- a/dw/table.cc +++ b/dw/table.cc @@ -52,7 +52,6 @@ Table::Table(bool limitTextWidth) colExtremes = new misc::SimpleVector (8); colWidthSpecified = new misc::SimpleVector (8); colWidthPercentage = new misc::SimpleVector (8); - cumHeight = new misc::SimpleVector (8); rowSpanCells = new misc::SimpleVector (8); baseline = new misc::SimpleVector (8); rowStyle = new misc::SimpleVector (8); @@ -92,7 +91,6 @@ Table::~Table() delete colExtremes; delete colWidthSpecified; delete colWidthPercentage; - delete cumHeight; delete rowSpanCells; delete baseline; delete rowStyle; @@ -115,7 +113,7 @@ void Table::sizeRequestSimpl (core::Requisition *requisition) requisition->width += colWidths.at (col); requisition->ascent = - boxDiffHeight () + cumHeight->get (numRows) + getStyle()->vBorderSpacing; + boxDiffHeight () + cumHeight.at (numRows) + getStyle()->vBorderSpacing; requisition->descent = 0; correctRequisition (requisition, core::splitHeightPreserveDescent, true, @@ -192,12 +190,12 @@ void Table::sizeAllocateImpl (core::Allocation *allocation) children->get(n)->cell.widget->sizeRequest (&childRequisition); childAllocation.x = x; - childAllocation.y = cumHeight->get (row) + offy; + childAllocation.y = cumHeight.at (row) + offy; childAllocation.width = width; childAllocation.ascent = childRequisition.ascent; childAllocation.descent = - cumHeight->get (row + children->get(n)->cell.rowspan) - - cumHeight->get (row) - getStyle()->vBorderSpacing + cumHeight.at (row + children->get(n)->cell.rowspan) + - cumHeight.at (row) - getStyle()->vBorderSpacing - childRequisition.ascent; children->get(n)->cell.widget->sizeAllocate (&childAllocation); } @@ -920,7 +918,7 @@ void Table::actuallyCalcCellSizes (bool calcHeights) boxDiffWidth (), totalWidth); assert (colWidths.size () == numCols); // This is set in addCell. - cumHeight->setSize (numRows + 1, 0); + cumHeight.resize (numRows + 1, 0); rowSpanCells->setSize (0); baseline->setSize (numRows); @@ -1213,7 +1211,7 @@ void Table::actuallyCalcCellSizes (bool calcHeights) } // for col setCumHeight (row + 1, - cumHeight->get (row) + rowHeight + getStyle()->vBorderSpacing); + cumHeight.at (row) + rowHeight + getStyle()->vBorderSpacing); } // for row apportionRowSpan (); @@ -1232,7 +1230,7 @@ void Table::apportionRowSpan () int n = rowSpanCells->get(c); int row = n / numCols; int rs = children->get(n)->cell.rowspan; - int sumRows = cumHeight->get(row+rs) - cumHeight->get(row); + int sumRows = cumHeight.at(row+rs) - cumHeight.at(row); core::Requisition childRequisition; children->get(n)->cell.widget->sizeRequest (&childRequisition); int spanHeight = childRequisition.ascent + childRequisition.descent @@ -1248,7 +1246,7 @@ void Table::apportionRowSpan () if (!rowHeight) { rowHeight = new int[numRows]; for (int i = 0; i < numRows; i++) - rowHeight[i] = cumHeight->get(i+1) - cumHeight->get(i); + rowHeight[i] = cumHeight.at(i+1) - cumHeight.at(i); } #ifdef DBG MSG(" rowHeight { "); @@ -1276,7 +1274,7 @@ void Table::apportionRowSpan () } // Update cumHeight for (int i = 0; i < numRows; ++i) - setCumHeight (i+1, cumHeight->get(i) + rowHeight[i]); + setCumHeight (i+1, cumHeight.at(i) + rowHeight[i]); } delete[] rowHeight; diff --git a/dw/table.hh b/dw/table.hh index 85c2724..9015ab4 100644 --- a/dw/table.hh +++ b/dw/table.hh @@ -409,7 +409,7 @@ private: * cumHeight->get(0) is 0, cumHeight->get(numRows) is the total table * height. */ - lout::misc::SimpleVector *cumHeight; + std::vector< int > cumHeight; /** * If a Cell has rowspan > 1, it goes into this array */ @@ -457,9 +457,9 @@ private: void setCumHeight (int row, int value) { - if (value != cumHeight->get (row)) { + if (value != cumHeight.at (row)) { redrawY = std::min ( redrawY, value ); - cumHeight->set (row, value); + cumHeight[ row ]= value; } }