Skip to content

Commit fae0111

Browse files
committed
refactor: clean up old code
1 parent 04bb602 commit fae0111

File tree

1 file changed

+6
-43
lines changed

1 file changed

+6
-43
lines changed

src/Evaluate.jl

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ macro return_on_nonfinite_val(eval_options, val, X)
1616
:(
1717
if $(esc(eval_options)).early_exit isa Val{true} && !is_valid($(esc(val)))
1818
return $(ResultOk)(
19-
_similar($(esc(X)), $(esc(eval_options)), axes($(esc(X)), 2)), false
19+
get_array($(esc(eval_options)).buffer, $(esc(X)), axes($(esc(X)), 2)), false
2020
)
2121
end
2222
)
@@ -258,8 +258,11 @@ function _eval_tree_array(
258258
elseif is_constant(tree)
259259
# Speed hack for constant trees.
260260
const_result = dispatch_constant_tree(tree, operators)::ResultOk{T}
261-
!const_result.ok && return ResultOk(_similar(cX, eval_options, axes(cX, 2)), false)
262-
return ResultOk(_fill_similar(const_result.x, cX, eval_options, axes(cX, 2)), true)
261+
!const_result.ok &&
262+
return ResultOk(get_array(eval_options.buffer, cX, axes(cX, 2)), false)
263+
return ResultOk(
264+
get_filled_array(eval_options.buffer, const_result.x, cX, axes(cX, 2)), true
265+
)
263266
elseif tree.degree == 1
264267
op_idx = tree.op
265268
return dispatch_deg1_eval(tree, cX, op_idx, operators, eval_options)
@@ -306,46 +309,6 @@ function deg0_eval(
306309
end
307310
end
308311

309-
function _reset_buffer_ref!(eval_options::EvalOptions)
310-
if eval_options.buffer_ref !== nothing
311-
eval_options.buffer_ref[] = 1
312-
end
313-
return nothing
314-
end
315-
function _fill_similar(value, array, eval_options::EvalOptions, args...)
316-
if eval_options.buffer === nothing
317-
return fill_similar(value, array, args...)
318-
else
319-
# TODO HACK: Treat `axes` here explicitly!
320-
i = eval_options.buffer_ref[]
321-
out = @view(eval_options.buffer[i, :])
322-
out .= value
323-
eval_options.buffer_ref[] = i + 1
324-
return out
325-
end
326-
end
327-
function _similar(X, eval_options::EvalOptions, args...)
328-
if eval_options.buffer === nothing
329-
return similar(X, args...)
330-
else
331-
i = eval_options.buffer_ref[]
332-
out = @view(eval_options.buffer[i, :])
333-
eval_options.buffer_ref[] = i + 1
334-
return out
335-
end
336-
end
337-
function _index_X(X, feature, eval_options::EvalOptions)
338-
if eval_options.buffer === nothing
339-
return X[feature, :]
340-
else
341-
i = eval_options.buffer_ref[]
342-
out = @view(eval_options.buffer[i, :])
343-
eval_options.buffer_ref[] = i + 1
344-
out .= X[feature, :]
345-
return out
346-
end
347-
end
348-
349312
@generated function dispatch_deg2_eval(
350313
tree::AbstractExpressionNode{T},
351314
cX::AbstractMatrix{T},

0 commit comments

Comments
 (0)