Skip to content

Conversation

dishmaker
Copy link
Contributor

Sometimes, when encoding big DER structures, value_len gets called many times.

In order to limit amount of recursive calls, this wrapper caches the computed length,
until the value gets encoded.

Sometimes, when encoding big DER structures, value_len gets called many times.
In order to limit amount of recursive calls, this wrapper caches the computed length,
until the value gets encoded.
@tarcieri
Copy link
Member

Using a newtype for this seems pretty heavy-handed. Perhaps there's an alternative solution that can reduce the number of calls?

Do you have a specific example of where this is problematic? Could those types handle caching the length themselves?

@dishmaker
Copy link
Contributor Author

I don't have an example. This just seems to be reasonable, where PKCS#15 nests objects recursively (example)
Actually, this newtype can be in a separate crate.

@dishmaker dishmaker marked this pull request as draft July 18, 2025 09:09
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

Successfully merging this pull request may close these issues.

2 participants