sisl / GridInterpolations.jl

Multidimensional grid interpolation in arbitrary dimensions
Other
52 stars 12 forks source link

Unnecessary heap allocation? #41

Closed himanshugupta1009 closed 8 months ago

himanshugupta1009 commented 9 months ago

This line https://github.com/sisl/GridInterpolations.jl/blob/fa8cd12253713b3a236d04128c69936533d5c0c9/src/GridInterpolations.jl#L231 allocates new vectors.

It seems like over-optimization to save a few Float computations at the expense of allocations which stresses the garbage collector. Is there a way to get around it? If not, is it possible to just avoid the extra check performed at line 229?

Thanks!

mykelk commented 9 months ago

Thanks for the idea! Feel free to contribute a PR with some empirical results on timing.

himanshugupta1009 commented 8 months ago

I have created a PR for this issue with some empirical results. If there are any issues with it, let me know. Thanks!