Skip to content

Commit 3da9474

Browse files
committed
Apply suggestion
1 parent 8249279 commit 3da9474

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/FindFirstFunctions.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,14 @@ function (g::Guesser)(x)
238238
f > 0 ? lastindex(v) : firstindex(v)
239239
else
240240
i_0, i_f = firstindex(v), lastindex(v)
241-
i_appr = f * (i_f - i_0) + i_0
242-
target_type = typeof(firstindex(v))
243-
if typemin(target_type) <= i_appr <= typemax(target_type)
244-
round(target_type, i_appr)
241+
i_approx = f * (i_f - i_0) + i_0
242+
target_type = eltype(v)
243+
if i_approx <= typemin(target_type)
244+
firstindex(v) - 1
245+
elseif i >= typemax(target_type)
246+
lastindex(v) + 1
245247
else
246-
idx_prev[]
248+
round(target_type, i_appr)
247249
end
248250
end
249251
else

0 commit comments

Comments
 (0)