Skip to content

Stop destructive updates to path in setPath#808

Merged
jdmarshall merged 2 commits intonode-config:masterfrom
jdmarshall:preparation
May 28, 2025
Merged

Stop destructive updates to path in setPath#808
jdmarshall merged 2 commits intonode-config:masterfrom
jdmarshall:preparation

Conversation

@jdmarshall
Copy link
Copy Markdown
Collaborator

@jdmarshall jdmarshall commented May 16, 2025

Simplify setModuleDefaults and getImpl/setPath to getPath/setPath

I believe I have finally cracked how to split up lib/config.js

This is some low-hanging fruit that simplifies the rest.

@jdmarshall jdmarshall requested a review from markstos May 17, 2025 23:43
@jdmarshall
Copy link
Copy Markdown
Collaborator Author

Okay, I have the big PR queued up and it would be a bit smaller if this one landed.

@jdmarshall
Copy link
Copy Markdown
Collaborator Author

jdmarshall commented May 19, 2025

Note: this is a little slower, but the slowdown is proportional to the key depth, which for config is usually pretty short.

Local benchmark: shift is about 6 times faster than slice with an array of 100k entries, but only twice as fast for an array of 10k entries.

Meanwhile we are more likely to be doing lookups of depth 5-8.

@jdmarshall
Copy link
Copy Markdown
Collaborator Author

I have 2 PRs open at the moment and they're a lot.

I will file a PR to make this function iterative after those land and that will make this function a lot simpler to trace and remove the slice() calls.

@jdmarshall jdmarshall added the 4.0 label May 22, 2025
@jdmarshall jdmarshall merged commit 8303498 into node-config:master May 28, 2025
1 check passed
@jdmarshall jdmarshall deleted the preparation branch January 18, 2026 20:06
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