neocturne / fastd

Fast and Secure Tunnelling Daemon
Other
119 stars 16 forks source link

avoid passing by value for const attribs #9

Closed smoe closed 4 years ago

smoe commented 4 years ago

Please kindly treat this as a presubmission enquiry. I would continue local development if you consider this useful. But of course, I'd feel just as honoured if you decide to just snap this from me :o)

I went through a few functions in buffer.[ch] and looked at what arguments remain invariant during the execution of these functions and if I had felt that this was not just some accident then I added a "const" to the declaration/definition. And when you pass a struct by value that is not changed, then I suggest to pass a pointer to that struct, instead.

I hope I have not messed anything up - I failed to invoke the test routines on this end, meson was too much fo me, but it compiles. If I did not destroy the semantics by accident [and if, maybe this is still fixable], since these buffer routines are executed with every package if I get this right, this should be rather beneficial to the performance.

neocturne commented 4 years ago

I'm currently in the middle of completely rewriting the buffer management of fastd (with the goal to avoid all dynamic allocation at runtime, and eventually supporting io_uring), so I can't accept this PR at this time.