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

Consider providing hash implementation for public types #23

Open
dmtrKovalenko opened this issue Mar 26, 2024 · 5 comments
Open

Consider providing hash implementation for public types #23

dmtrKovalenko opened this issue Mar 26, 2024 · 5 comments

Comments

@dmtrKovalenko
Copy link

dmtrKovalenko commented Mar 26, 2024

This will involve some work around the floats to make them hashable. In the case of SVG types I think we can even do the simple .to_bits().hash() with additional check for the NaN value, but also we can use more robust way like https://github.com/reem/rust-ordered-float/blob/master/src/lib.rs

If you accept this I can open a PR

@RazrFalcon
Copy link
Collaborator

Can you provide a use case?

@dmtrKovalenko
Copy link
Author

Cache individual svg elements rendered canvases based on the declaration

@RazrFalcon
Copy link
Collaborator

It would be highly problematic to implement. Not to mention very slow. usvg nodes are very complex. Text alone has like 50 properties.
I would suggest using element IDs, assuming they are present.

In the worst case we could try adding UUID for each node, so it could be used for hash instead.

@dmtrKovalenko
Copy link
Author

I already have a fork of your repo with hash implementation and rerendering the element is much slower than hashing every node.

Using ids is not possible because I need to specifically detect if the element was changed.

@RazrFalcon
Copy link
Collaborator

Of course rendering is slower, but slow caching isn't a solution either. I will think about it. For now just fork.

Using ids is not possible because I need to specifically detect if the element was changed.

Elements are immutable since recently.

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

2 participants