Skip to content

Commit

Permalink
Merge pull request #3 from JuliaComputing/s/searchsorted
Browse files Browse the repository at this point in the history
use `searchsortedfirst` in `getpoolidx`
  • Loading branch information
shashi authored May 10, 2017
2 parents 47e6b14 + e42e4d7 commit ed9eef5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/PooledArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ Base.getindex(A::PooledArray, I::AbstractArray) =

function getpoolidx{T,R}(pa::PooledArray{T,R}, val::Any)
val::T = convert(T,val)
pool_idx = findfirst(pa.pool, val)
if pool_idx <= 0
pool_idx = searchsortedfirst(pa.pool, val)
if pool_idx > length(pa.pool) || pa.pool[pool_idx] != val
pool_idx = unsafe_pool_push!(pa, val)
end
return pool_idx
Expand Down

0 comments on commit ed9eef5

Please sign in to comment.