Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChainMap: Avoid a redundant internal weak map. #30258

Merged
merged 1 commit into from
Jan 3, 2025
Merged

Conversation

ycw
Copy link
Contributor

@ycw ycw commented Jan 3, 2025

Description

Issue: ChainMap holds value in a redundant weakmap, see https://jsfiddle.net/rebw4hvn/:

chainMap.set([key0, key1], value)

// expected
chainMap.weakMap.get(key0).get(key1) === value

// actual
chainMap.weakMap.get(key0).get(key1).get(key1) === value

This PR fixed that by using just enough weakmaps.

Copy link

github-actions bot commented Jan 3, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.49
79.09
339.49
79.09
+0 B
+0 B
WebGPU 489.82
135.88
489.83
135.88
+6 B
+5 B
WebGPU Nodes 489.29
135.76
489.29
135.77
+6 B
+6 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.35
112.14
465.35
112.14
+0 B
+0 B
WebGPU 559.3
151.37
559.31
151.37
+6 B
+1 B
WebGPU Nodes 515.38
141.15
515.38
141.15
+6 B
-1 B

@ycw ycw requested a review from Mugen87 January 3, 2025 16:46
@Mugen87 Mugen87 changed the title Improves ChainMap ChainMap: Avoid a redundant internal weak map. Jan 3, 2025
@Mugen87 Mugen87 added this to the r173 milestone Jan 3, 2025
@sunag sunag merged commit 8e6507f into mrdoob:dev Jan 3, 2025
12 checks passed
@ycw ycw deleted the fix-chainmap branch January 3, 2025 18:25
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.

3 participants