Skip to content

Commit b3b0416

Browse files
jishnubKristofferC
authored andcommitted
LAPACK: Avoid repr call in chkvalidparam (#54952)
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`. (cherry picked from commit ca0b2a8)
1 parent 744b24d commit b3b0416

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stdlib/LinearAlgebra/src/lapack.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ macro chkvalidparam(position::Int, param, validvalues)
6161
:(chkvalidparam($position, $(string(param)), $(esc(param)), $validvalues))
6262
end
6363
function chkvalidparam(position::Int, var::String, val, validvals)
64+
# mimic `repr` for chars without explicitly calling it
65+
# This is because `repr` introduces dynamic dispatch
66+
_repr(c::AbstractChar) = "'$c'"
67+
_repr(c) = c
6468
if val validvals
6569
throw(ArgumentError(
66-
lazy"argument #$position: $var must be one of $validvals, but $(repr(val)) was passed"))
70+
lazy"argument #$position: $var must be one of $validvals, but $(_repr(val)) was passed"))
6771
end
6872
return val
6973
end

0 commit comments

Comments
 (0)