Skip to content

Commit

Permalink
micro-optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Mar 28, 2024
1 parent 6df7fea commit 037f0ff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Maui.DataGrid/DataGridRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ private void InitializeRow()

UpdateColors();

if (DataGrid.Columns == null || DataGrid.Columns.Count == 0)
var columns = DataGrid.Columns;

if (columns == null || columns.Count == 0)
{
ColumnDefinitions.Clear();
return;
}

var isEditing = RowToEdit == BindingContext;

var columnCount = DataGrid.Columns.Count;
var columnCount = columns.Count;

for (var i = 0; i < columnCount; i++)
{
Expand Down Expand Up @@ -106,7 +108,7 @@ private void InitializeRow()
}

// Remove extra columns, if any
ColumnDefinitions.RemoveAfter(DataGrid.Columns.Count);
ColumnDefinitions.RemoveAfter(columnCount);
}

private DataGridCell GenerateCellForColumn(DataGridColumn col, int columnIndex)
Expand Down

0 comments on commit 037f0ff

Please sign in to comment.