@@ -114,18 +114,20 @@ function bezier(p::Matrix{<:Real}; t=nothing, np::Int=0, pure=false, firstcurve=
114114end
115115
116116function helper_bezier_cb (o:: Matrix{Float64} , p:: Matrix{Float64} , t, firstcurve:: Bool ):: Matrix{Float64}
117- # Made this function barrier to restrict the Core.box. For some incomprehensible reason, 'o' becomes
118- # a Core.box and that happens due to the appending (the 'vcats' below). Both Cthulhu and the debugger
119- # show that 'o' is no longer a Core.box when it lands on the calling function.
120117 # This function is not efficient due to the matrix concatenations, but it's not expeced to cat much data.
121118 for k = 5 : size (p, 1 )
122119 oo = bezier (p[k- 3 ,:], p[k- 2 ,:], p[k- 1 ,:], p[k,:]; t= t)
120+ d = Vector {Float64} (undef, size (oo, 1 ))
123121 if (firstcurve)
124122 xn = o[end ,1 ]; yn = o[end ,2 ]; zn = o[end ,3 ]
125- d:: Vector{Float64} = [(oo[n,1 ] - xn)^ 2 + (oo[n,2 ] - yn)^ 2 + (oo[n,3 ] - zn)^ 2 for n = 1 : size (oo, 1 )]
123+ @inbounds for n = 1 : size (oo, 1 )
124+ d[n] = (oo[n,1 ] - xn)^ 2 + (oo[n,2 ] - yn)^ 2 + (oo[n,3 ] - zn)^ 2
125+ end
126126 else
127127 xn = oo[1 ,1 ]; yn = oo[1 ,2 ]; zn = oo[1 ,3 ]
128- d = [(o[n,1 ] - xn)^ 2 + (o[n,2 ] - yn)^ 2 + (o[n,3 ] - zn)^ 2 for n = 1 : size (oo, 1 )]
128+ @inbounds for n = 1 : size (oo, 1 )
129+ d[n] = (o[n,1 ] - xn)^ 2 + (o[n,2 ] - yn)^ 2 + (o[n,3 ] - zn)^ 2
130+ end
129131 end
130132 m = argmin (d)
131133 o = firstcurve ? vcat (o, oo[m+ 1 : end ,:]) : vcat (o[1 : m,:], oo)
0 commit comments