Skip to content

Commit

Permalink
use searchsortedfirst in getpoolidx
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashi Gowda committed May 10, 2017
1 parent 57e0589 commit e42e4d7
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 e42e4d7

Please sign in to comment.