Skip to content

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Jun 12, 2025

Motivation

Solution

Open questions

Copy link

changeset-bot bot commented Jun 12, 2025

⚠️ No Changeset found

Latest commit: 047331f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Jun 12, 2025

Size Change: +22 B (+0.03%)

Total Size: 77.7 kB

Filename Size Change
examples/test-bundlesize/dist/rdcClient.js 10.2 kB +22 B (+0.22%)
ℹ️ View Unchanged
Filename Size
examples/test-bundlesize/dist/App.js 3.42 kB
examples/test-bundlesize/dist/polyfill.js 311 B
examples/test-bundlesize/dist/rdcEndpoint.js 5.61 kB
examples/test-bundlesize/dist/react.js 57.5 kB
examples/test-bundlesize/dist/webpack-runtime.js 726 B

compressed-size-action

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 047331f Previous: b10128e Ratio
normalizeLong 536 ops/sec (±1.59%) 532 ops/sec (±1.01%) 0.99
denormalizeLong 285 ops/sec (±2.34%) 293 ops/sec (±1.96%) 1.03
denormalizeLong donotcache 1025 ops/sec (±1.53%) 1035 ops/sec (±1.25%) 1.01
denormalizeShort donotcache 500x 1600 ops/sec (±0.15%) 1581 ops/sec (±0.30%) 0.99
denormalizeShort 500x 861 ops/sec (±1.59%) 868 ops/sec (±1.78%) 1.01
denormalizeShort 500x withCache 6556 ops/sec (±0.10%) 6600 ops/sec (±0.08%) 1.01
queryShort 500x withCache 2832 ops/sec (±0.10%) 2728 ops/sec (±0.14%) 0.96
buildQueryKey All 53300 ops/sec (±0.33%) 55270 ops/sec (±0.25%) 1.04
query All withCache 7004 ops/sec (±0.27%) 6899 ops/sec (±0.21%) 0.99
denormalizeLong with mixin Entity 276 ops/sec (±1.87%) 281 ops/sec (±1.83%) 1.02
denormalizeLong withCache 6609 ops/sec (±0.11%) 6930 ops/sec (±0.19%) 1.05
denormalizeLong All withCache 6728 ops/sec (±0.14%) 6644 ops/sec (±0.12%) 0.99
denormalizeLong Query-sorted withCache 7063 ops/sec (±0.17%) 6951 ops/sec (±0.12%) 0.98
denormalizeLongAndShort withEntityCacheOnly 1699 ops/sec (±1.35%) 1769 ops/sec (±0.20%) 1.04
getResponse 5924 ops/sec (±1.46%) 5747 ops/sec (±1.25%) 0.97
getResponse (null) 7537016 ops/sec (±0.81%) 6655816 ops/sec (±0.61%) 0.88
getResponse (clear cache) 275 ops/sec (±1.69%) 270 ops/sec (±1.72%) 0.98
getSmallResponse 3096 ops/sec (±0.21%) 3118 ops/sec (±0.11%) 1.01
getSmallInferredResponse 2392 ops/sec (±0.07%) 2354 ops/sec (±0.14%) 0.98
getResponse Collection 5849 ops/sec (±1.22%) 5705 ops/sec (±1.35%) 0.98
get Collection 5955 ops/sec (±0.17%) 5896 ops/sec (±0.30%) 0.99
get Query-sorted 6978 ops/sec (±0.19%) 6762 ops/sec (±0.21%) 0.97
setLong 537 ops/sec (±0.23%) 545 ops/sec (±0.19%) 1.01
setLongWithMerge 242 ops/sec (±0.13%) 244 ops/sec (±0.35%) 1.01
setLongWithSimpleMerge 255 ops/sec (±0.15%) 263 ops/sec (±0.21%) 1.03
setSmallResponse 500x 960 ops/sec (±0.09%) 966 ops/sec (±0.16%) 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@ntucker ntucker force-pushed the norm-imm branch 2 times, most recently from 24e119b to 008fc9c Compare June 27, 2025 12:31
@ntucker ntucker requested a review from Copilot August 10, 2025 05:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the normalization process to use a more streamlined approach where NormalizeDelegate directly implements the NormalizedSchema interface, eliminating the need for a separate return object. The key change moves from creating a separate normalized result object to having the delegate itself serve as the normalized schema.

Key changes:

  • Refactored normalize() function to return the delegate directly instead of a separate result object
  • Updated NormalizeDelegate to implement NormalizedSchema interface with declared properties
  • Reorganized internal tracking from separate maps to a nested structure under this.new

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/normalizr/src/normalize/normalize.ts Simplified normalize function to return delegate directly instead of creating separate result object
packages/normalizr/src/normalize/NormalizeDelegate.ts Enhanced delegate to implement NormalizedSchema interface and reorganized internal state tracking

);
const visit = getVisit(delegate);
delegate.result = visit(schema, input, input, undefined, args);
return delegate as any;
Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'as any' type assertion bypasses TypeScript's type checking. Consider defining proper type annotations or ensuring the delegate properly implements the expected return type to maintain type safety.

Suggested change
return delegate as any;
return {
result: delegate.result,
entities: delegate.entities,
indexes: delegate.indexes,
entitiesMeta: delegate.entitiesMeta,
};

Copilot uses AI. Check for mistakes.

// entities: { ...state.entities },
// indexes: { ...state.indexes },
// entitiesMeta: { ...state.entitiesMeta },
// };
Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This large block of commented code should be removed as it adds clutter and doesn't provide value. If this is temporary implementation notes, consider using TODO comments instead.

Suggested change
// };
// TODO: Assign to this.normalized if/when needed.

Copilot uses AI. Check for mistakes.

{
// declare readonly normalized: NormalizedSchema<E, R>;
Copy link
Preview

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commented declare statement should be removed as it's unused and adds confusion about the class structure.

Suggested change
// declare readonly normalized: NormalizedSchema<E, R>;

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant