reduce allocations in CalculatePointedCell

This commit is contained in:
Morilli 2024-03-16 13:26:53 +01:00
parent cad3699221
commit bfae8d0f1e
1 changed files with 3 additions and 4 deletions

View File

@ -1844,10 +1844,9 @@ namespace BizHawk.Client.EmuHawk
private Cell CalculatePointedCell(int x, int y)
{
var newCell = new Cell();
var columns = _columns.VisibleColumns.ToList();
// If pointing to a column header
if (columns.Any())
if (_columns.VisibleColumns.Any())
{
if (HorizontalOrientation)
{
@ -1890,10 +1889,10 @@ namespace BizHawk.Client.EmuHawk
if (_horizontalOrientation)
{
return _columns.VisibleColumns.Select(static (n, i) => (Column: n, Index: i))
.FirstOrNull(item => (GetHColTop(item.Index) - _vBar.Value).RangeTo(GetHColBottom(item.Index) - _vBar.Value).Contains(pixel))
.FirstOrNull(item => pixel >= GetHColTop(item.Index) - _vBar.Value && pixel <= GetHColBottom(item.Index) - _vBar.Value)
?.Column;
}
return _columns.VisibleColumns.FirstOrDefault(column => (column.Left - _hBar.Value).RangeTo(column.Right - _hBar.Value).Contains(pixel));
return _columns.VisibleColumns.FirstOrDefault(column => pixel >= column.Left - _hBar.Value && pixel <= column.Right - _hBar.Value);
}
/// <summary>