paulirwin commented on issue #1062:
URL: https://github.com/apache/lucenenet/issues/1062#issuecomment-2525267423

   @Shazwazza Thanks, I made the no-capture lambda case static and it was the 
same result, so I'm guessing .NET was already optimizing it that way. The 
others I can't make static because they capture, like you said. It would be 
nice if .NET somehow could optimize a non-static lambda to not be more costly 
than an object that implements a functional interface...
   
   Inspired by your comment about overloads, perhaps we could add overloads 
that take a delegate but then store it in a lucenenet-specific implementation 
of the interface that just calls the delegate, so that the underlying stored 
reference is the functional interface type instead of a delegate. This would 
probably be the best of both worlds: allow for ease of use in the API by 
passing a lambda if you're not concerned about a few ns/op or 64 extra bytes 
allocated, but allow for passing an object that implements the interface for 
more performance-critical scenarios. I'll experiment with this approach and see 
how it feels. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to