Skip to content

Conversation

@jac3km4
Copy link

@jac3km4 jac3km4 commented Feb 10, 2024

Hi, thanks for this library, it's pretty neat.

I intend to use a slightly changed version of it for a project, there are a few changes I made. I'd be happy to contribute it back if you like the changes.
The first thing I noticed is that the fact that the Ctx types are enums often makes the generated code inefficient, because the compiled functions contain pattern matches unless the compiler manages to optimize them out, which is pretty unpredictable. Protocols almost never require dynamically switching between Little-Endian and Big-Endian and so on, so it might be better to use individual types.
In this PR I replace the enums with concrete types:

  • LittleEndian
  • BigEndian
  • Len
  • Pattern
  • PatternUntil
  • Delimiter
  • DelimiterUntil

I've also added a benchmark that reads and writes numeric types. On my machine this benchmark shows a 10-15% improvement on numeric code and much smaller code size.

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.

1 participant