After removing Base.getproperty
, you need to check if the exported API is type stable and how the performance changes.
|
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 |
|
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 |