Skip to content

Commit

Permalink
LAPACK: Avoid repr call in chkvalidparam (JuliaLang#54952)
Browse files Browse the repository at this point in the history
We were calling `repr` here to interpolate the character with the quotes
into the error message. However, this is overkill for this application,
and `repr` introduces dynamic dispatch into the call. This PR hard-codes
the quotes into the string, which matches the pattern followed in the
other error messages following `chkvalidparam`.
  • Loading branch information
jishnub committed Jun 27, 2024
1 parent 17e6e69 commit ca0b2a8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion stdlib/LinearAlgebra/src/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ macro chkvalidparam(position::Int, param, validvalues)
:(chkvalidparam($position, $(string(param)), $(esc(param)), $validvalues))
end
function chkvalidparam(position::Int, var::String, val, validvals)
# mimic `repr` for chars without explicitly calling it
# This is because `repr` introduces dynamic dispatch
_repr(c::AbstractChar) = "'$c'"
_repr(c) = c
if val validvals
throw(ArgumentError(
lazy"argument #$position: $var must be one of $validvals, but $(repr(val)) was passed"))
lazy"argument #$position: $var must be one of $validvals, but $(_repr(val)) was passed"))
end
return val
end
Expand Down

0 comments on commit ca0b2a8

Please sign in to comment.