Skip to content

Commit e5a6dd9

Browse files
committed
perf: return early in reconcileTagProps
1 parent b072099 commit e5a6dd9

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/tiny-react/src/compat/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ export function memo<P extends object>(
6262

6363
// from preact https://github.com/preactjs/preact/blob/4b1a7e9276e04676b8d3f8a8257469e2f732e8d4/compat/src/util.js#L19-L23
6464
function objectShallowEqual(x: object, y: object): boolean {
65+
if (x === y) {
66+
return true;
67+
}
6568
for (const k in x) {
6669
if (!(k in y)) {
6770
return false;

packages/tiny-react/src/reconciler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ function reconcileNode(
127127
preSlot,
128128
effectManager
129129
);
130+
// TODO: move bchild placing logic to parent? at least for mutating path?
130131
preSlot = getSlot(bchild) ?? preSlot;
131132
bnode.slot = getSlot(bchild) ?? bnode.slot;
132133
bnode.children[i] = bchild;
@@ -320,6 +321,9 @@ function alignChildrenByKey(
320321
// https://github.com/ryansolid/dom-expressions/blob/a2bd455055f5736bb591abe69a5f5b52568b9ea6/packages/babel-plugin-jsx-dom-expressions/src/dom/element.js#L219-L246
321322
// https://github.com/ryansolid/dom-expressions/blob/a2bd455055f5736bb591abe69a5f5b52568b9ea6/packages/dom-expressions/src/constants.js#L30-L39
322323
function reconcileTagProps(bnode: BTag, props: Props, oldProps: Props) {
324+
if (props === oldProps) {
325+
return;
326+
}
323327
for (const k in oldProps) {
324328
if (!(k in props)) {
325329
setTagProp(bnode, k, null);

0 commit comments

Comments
 (0)