Closed Bug 1619041 Opened 4 years ago Closed 4 years ago

Unnecessary check and increment in nsCellMap::HasMoreThanOneCell

Categories

(Core :: Layout: Tables, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla75
Tracking Status
firefox75 --- fixed

People

(Reporter: alexhenrie24, Assigned: alexhenrie24)

Details

Attachments

(1 file)

nsCellMap::HasMoreThanOneCell currently looks like this:

bool nsCellMap::HasMoreThanOneCell(int32_t aRowIndex) const {
  const CellDataArray& row = mRows.SafeElementAt(aRowIndex, *sEmptyRow);
  uint32_t maxColIndex = row.Length();
  uint32_t count = 0;
  uint32_t colIndex;
  for (colIndex = 0; colIndex < maxColIndex; colIndex++) {
    CellData* cellData = row[colIndex];
    if (cellData && (cellData->GetCellFrame() || cellData->IsRowSpan()))
      count++;
    if (count > 1) return true;
  }
  return false;
}

It's only necessary to check if count is greater than 1 if count has been incremented since the last time it was checked. Moreover, it's only necessary to increment count if it is not already equal to 1.

Assignee: nobody → alexhenrie24
Status: NEW → ASSIGNED
Pushed by dvarga@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/812f473fa40b
Avoid unnecessary operations in nsCellMap::HasMoreThanOneCell. r=dbaron
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: