libunifex icon indicating copy to clipboard operation
libunifex copied to clipboard

adding complete_adapt_stream algorithm

Open lehecka opened this issue 2 years ago • 3 comments

similar to next_adapt_steram, adding complete_adapt_stream

lehecka avatar Mar 23 '22 00:03 lehecka

Could this instead be written as using the existing adapt_stream algorithm but passing the identity function for the adapt_next param? That would make this algorithm more maintainable in the long run.

MarkCMann avatar Mar 23 '22 15:03 MarkCMann

I used the next_adapt_stream implementation as a template for this algorithm. I can see how both next_adapt_stream and complete_adapt_stream can be written on top of adapt_stream. I am assuming this would be more optimal implementation since it saves some bytes for storing the transformation lambda for the other signal which is not used.

lehecka avatar Mar 23 '22 17:03 lehecka

If the function is just an identity transformation then it shouldn't take up any additional space in the adapt_stream type (so long as the functions are annotated with [[no_unique_address]]). Check out this godbolt for an example of how wrapping an identity transform function doesn't require additional storage in the wrapper class.

MarkCMann avatar Mar 23 '22 20:03 MarkCMann