How can I find index of spline point

Thanks for answer I tried this way, but there are thousands of points in the spline and this is meaning very low fps. is there a way to do this without fps dropping.