From b3b04167f73b4315dd96bf5331ba3e2f3e7490d7 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 28 Jun 2024 00:07:53 +0530 Subject: [PATCH] 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 ca0b2a8887fb769c5046b184c269d955f0400bcb) --- stdlib/LinearAlgebra/src/lapack.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/LinearAlgebra/src/lapack.jl b/stdlib/LinearAlgebra/src/lapack.jl index 4b7bffcd50e89..30307d365251b 100644 --- a/stdlib/LinearAlgebra/src/lapack.jl +++ b/stdlib/LinearAlgebra/src/lapack.jl @@ -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