From e42e4d7b4888e621977844cf63952a13f2cd44ba Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Wed, 10 May 2017 22:08:35 +0530 Subject: [PATCH] use searchsortedfirst in getpoolidx --- src/PooledArrays.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PooledArrays.jl b/src/PooledArrays.jl index e3c5ffb..9c1ac15 100644 --- a/src/PooledArrays.jl +++ b/src/PooledArrays.jl @@ -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