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

Make a stateless fs.Prefix #3

Open
sdboyer opened this issue Mar 14, 2023 · 0 comments
Open

Make a stateless fs.Prefix #3

sdboyer opened this issue Mar 14, 2023 · 0 comments

Comments

@sdboyer
Copy link
Contributor

sdboyer commented Mar 14, 2023

There are some places in the code where we dynamically construct a Go fs.FS by injecting a prefix onto another fs.

https://github.com/grafana/grafana/blob/121e384fabdf01ca191c5a4da3df82094dd2fce7/pkg/cuectx/ctx.go#L230-L231

Currently, we accomplish this with a sloppy, heavyweight procedure: loop over the whole fsys we want to prefix, and copy each entry - file content bytes and all - using an fstest.MapFS.

It's a waste of both time and space. i'm not sure how much of a waste, but the implementation oughtn't be so bad that we have to do an exhaustive investigation to decide if it's worth it. Really, we want what Go stdlib has for fs.Sub, just in reverse.

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

No branches or pull requests

1 participant