This repository was archived by the owner on Sep 4, 2024. It is now read-only.
Simplify implementation for ImageTagSet equality#1116
Draft
Conversation
We're targeting netstandard2.0 and don't have ReadOnlySpan or any of the new APIs that avoid allocating
4bd008c to
25cb1aa
Compare
We cache the ImageTagSet directly now. That should allow us to create fewer of these instances overall. For the app I'm testing on, we cover 97% of the image tags combinations In practice, cache hits will be better overall. The other improvement is to not have to sort/create imagetagsets every time, instead opting to use more specialized APIs.
c63203a to
1557d48
Compare
Therzok
commented
Feb 21, 2023
| These tag items amount for 97% of the image tags found in images. | ||
| */ | ||
| readonly string[] knownTags = new[] { | ||
| "dark", |
Contributor
Author
There was a problem hiding this comment.
I don't know why I made the cache this way. Looking back, I think that we can store the original tags string and cache the ImageTagSet.
Contributor
Author
There was a problem hiding this comment.
Basically, we can have some presets, but cache tags that are added later as well.
Therzok
commented
Feb 21, 2023
|
|
||
| public ImageTagSet TryGetTagSet(string tags) | ||
| { | ||
| var index = Array.IndexOf(knownTags, tags); |
Contributor
Author
There was a problem hiding this comment.
Change to a list, and cache any tagset that isn't in the list already.
Therzok
commented
Feb 21, 2023
|
|
||
| public override IEnumerable<string> GetAlternativeFiles (string fileName, string baseName, string ext) | ||
| { | ||
| if (!Context.RegisteredStyles.Any ()) { |
Contributor
Author
There was a problem hiding this comment.
This check breaks my brain. I don't really understand why it is !Context.RegisteredStyles.Any()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.