Skip to content

Commit 94d9c30

Browse files
committed
Add some comments for future fixes
1 parent b1f1636 commit 94d9c30

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

packages/core/src/internal/data-grid/animation-manager.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export class AnimationManager {
5555
};
5656

5757
private getAnimatingItems = (): StateItem[] => {
58+
// this is horrible. We shoudl be mutating the array in place. The reason we don't right now is because the
59+
// hoveramount is used as both the tweened value and the raw value. We should separate these two things.
60+
// Then we can stop doing the allocation insanity dance.
5861
if (this.currentHoveredItem !== undefined) {
5962
return [...this.leavingItems, this.currentHoveredItem];
6063
}

packages/core/src/internal/data-grid/color-parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export function interpolateColors(leftColor: string, rightColor: string, val: nu
8585
if (val >= 1) return rightColor;
8686

8787
// Parse to rgba returns straight alpha colors, for interpolation we want pre-multiplied alpha
88+
// FIXME: This can be faster if instead of makign an array we just use variables. No memory allocation.
8889
const left = [...parseToRgba(leftColor)];
8990
left[0] = left[0] * left[3];
9091
left[1] = left[1] * left[3];

packages/core/src/internal/data-grid/data-grid-lib.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ export function gridSelectionHasItem(sel: GridSelection, item: Item): boolean {
5252
if (sel.columns.hasIndex(col) || sel.rows.hasIndex(row)) return true;
5353
if (sel.current !== undefined) {
5454
if (itemsAreEqual(sel.current.cell, item)) return true;
55-
const toCheck = [sel.current.range, ...sel.current.rangeStack];
55+
const toCheck = [sel.current.range, ...sel.current.rangeStack]; // FIXME: pointless alloc
5656
for (const r of toCheck) {
57+
// dont we have a function for this?
5758
if (col >= r.x && col < r.x + r.width && row >= r.y && row < r.y + r.height) return true;
5859
}
5960
}
@@ -465,7 +466,7 @@ export function getEmHeight(ctx: CanvasRenderingContext2D, fontStyle: string): n
465466
function truncateString(data: string, w: number): string {
466467
if (data.includes("\n")) {
467468
// new lines are rare and split is relatively expensive compared to the search
468-
// it pays off to not do the split contantly.
469+
// it pays off to not do the split contantly. More accurately... it pays off not to run the regex.
469470
data = data.split(/\r?\n/, 1)[0];
470471
}
471472
const max = w / 4; // no need to round, slice will just truncate this

0 commit comments

Comments
 (0)