-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Don't take a HighlightingAssets detour to build assets #1802
Conversation
Move code to build assets to its own file. That results in better modularity. It also allows us to simplify HighlitingAssets a lot, since it will now always be initialized with a SerializedSyntaxSet (see next commit).
I like this change - thank you very much! |
I've done some additional sanity-checking, and everything seems to work. Do you want to do a detailed review before I merge, @sharkdp ? |
I have a (nitpicky) question concerning the deprecate+always-return-error strategy. I'm not even sure if anyone is using this API, so this might be a completely hypothetical scenario. As a user of this library, out of the three ways to handle this…
… I think I would prefer 1 or 2. What I would like to avoid is to have my own software still compile*, but change its runtime behavior (option 3). * with a warning what do you think @Enselic? |
@sharkdp Good point, it might very well be better to remove the methods completely in this case. I don't think 1 is an option for us here, because with 1, we could not make the nice simplification with So I think we should go ahead with 2 then instead. Sounds OK? |
Yes - thank you. |
In the current code base, it is necessary to create a temporary
HighlightingAssets
instance to be able to build assets.This PR moves the code to build assets to its own place, independent of
HighlightingAssets
. This allows us to significantly simplifyHighlightingAssets
since we can makeSerializedSyntaxSet
mandatory.This also makes sense on a conceptual level. When building assets, it will never be necessary to also highlight source code. So it makes sense to stop using
HighlightingAssets
for this.This means that we no longer allow clients of our API to build assets during startup. But that is very slow, and I can't imagine why anyone would want to do that. And this simplification is worth a lot in terms of flexibility. So IMHO it is worth having to deprecate API.
New public API
I currently put the new API at
bat::assets::build
to not introduce a new module. Another option I was considering was
bat::build_assets
. I am open to further ideas.Deprecated and no longer functional API
bat::assets::HighlightingAssets::from_files
bat::assets::HighlightingAssets::save_to_cache
Background information
As I was experimenting with zero-copy deserialization (see #1787) I bumped into the problem of having to use
HighlightingAssets
to build assets. To support zero-copy deserialization, it will be natural to serialize temporarily owned data. Having to take aHighlightingAssets
detour really complicates things.But IMO this PR has merits of its own, regardless of the work related to #1787.
Status of PR
I'm happy with the code, and consider it ready for CR. But I have not yet done broad verification. I would prefer to get your thoughts on this before I put much time on verification. In case you think this is way too wild :)