[optimize] speed up diffKeys() with native Set intersection/difference semantics#34
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Speed up diffKeys() with new Set() API
Optimize Jun 30, 2026
diffKeys() with Set intersection/difference semantics
TechQuery
requested changes
Jun 30, 2026
Contributor
Author
|
已按评审意见改为直接使用最新 Set API,移除了兼容性 fallback。提交:5017736 |
Copilot
AI
changed the title
Optimize
Optimize Jun 30, 2026
diffKeys() with Set intersection/difference semanticsdiffKeys() with native Set intersection/difference semantics
There was a problem hiding this comment.
Pull request overview
This PR refactors diffKeys() to use set-based semantics for classifying keys as Old/Same/New, and adds a regression test to ensure duplicate keys don’t affect the classification results.
Changes:
- Reworked
diffKeys()to derive Old/Same/New sets fromoldListandnewList. - Added a unit test ensuring duplicate keys are ignored during comparison.
- Bumped package version to
4.7.1.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| source/data.ts | Refactors diffKeys() to compute key statuses using Set-based logic. |
| test/data.spec.ts | Adds coverage to ensure duplicates do not skew diffKeys() results. |
| package.json | Bumps the published package version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TechQuery
approved these changes
Jul 1, 2026
diffKeys() with native Set intersection/difference semanticsdiffKeys() with native Set intersection/difference semantics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
diffKeys()previously built status maps via two array passes and per-item mutation. This update moves key comparison to set algebra, reducing duplicate work and aligning behavior with modernSetAPIs.Set-based key diff core
diffKeys()to compareoldList/newListviaSetoperations:old \ new→DiffStatus.Oldold ∩ new→DiffStatus.Samenew \ old→DiffStatus.Newmap+ grouped entries).Native latest-API usage
Set.prototype.difference()andSet.prototype.intersection()directly (no built-in compatibility fallback).Deterministic duplicate handling
Human changes