-
Notifications
You must be signed in to change notification settings - Fork 14
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
Idea on package.json
approach
#7
Comments
@isiahmeadows thanks for putting this together. we know the lookup process in node will not be a problem and will not add a significant perf penalty, but it is nice to have your code around in case they ask for prove :) |
@caridy Welcome 😄 Another thing about doing it that way is that the memory is likely going to be much smaller than the naïve implementation. V8 stores strings as persistent cons cells IIRC, and smaller strings means they're more likely to be reused internally within larger strings. If I'm wrong about that, then the memory gains will be even larger. For what it's worth, I've done similar in my WIP test framework. The only difference is that I had to use arrays for the children because I needed to match against regexps as well. |
Edit: fix a couple small bugs.
I was thinking of an idea that might speed up the
package.json
approach, making it much quicker to check, which should keep the loading time minimal. Thepackage.json
will still need to be located, but that can be done in a similar search as what's done fornode_modules
now.package.json
fields relevant for this (e.g.modules
,modules.root
) queryable in a cache trie, so it can be quickly tested, almost constant time in practice.package.json
was found in the above search, then thepackage.json
should be found, and the file's parent directory added to the cache.I've also prepared this gist to show what I mean better. One of those is a very high-level, unoptimized version, and the other is a more low-level, optimized equivalent that avoids allocation, although neither is tested.
With that gist, you would basically do this:
The text was updated successfully, but these errors were encountered: