JuliaCrypto/SHA.jl

Remove `Base.getproperty`

inkydragon opened this issue · 2 comments

After removing Base.getproperty, you need to check if the exported API is type stable and how the performance changes.

SHA.jl/src/types.jl

Lines 42 to 54 in 918aff1

function Base.getproperty(ctx::SHA2_CTX, fieldname::Symbol)
if fieldname === :state
return getfield(ctx, :state)::Union{Vector{UInt32},Vector{UInt64}}
elseif fieldname === :bytecount
return getfield(ctx, :bytecount)::Union{UInt64,UInt128}
elseif fieldname === :buffer
return getfield(ctx, :buffer)::Vector{UInt8}
elseif fieldname === :W
return getfield(ctx, :W)::Vector{UInt32}
else
error("SHA2_CTX has no field ", fieldname)
end
end

SHA.jl/src/types.jl

Lines 90 to 102 in 918aff1

function Base.getproperty(ctx::SHA3_CTX, fieldname::Symbol)
if fieldname === :state
return getfield(ctx, :state)::Vector{UInt64}
elseif fieldname === :bytecount
return getfield(ctx, :bytecount)::UInt128
elseif fieldname === :buffer
return getfield(ctx, :buffer)::Vector{UInt8}
elseif fieldname === :bc
return getfield(ctx, :bc)::Vector{UInt64}
else
error("type ", typeof(ctx), " has no field ", fieldname)
end
end

@staticfloat I think it is safe to close this based on the linked PR :D

it is safe to close this

Nope, Base.getproperty is still in the code base.

We may need to check the type stability and performance of each API after removing getproperty.
I will open a new issue to track this. (77)

This issue is opened after pr 75.