Skip to content

Commit 6e5d1e2

Browse files
committed
Backport "Avoid concatenating LazyString in setindex! for triangular matrices #54631" to v1.11
1 parent 38c0772 commit 6e5d1e2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

stdlib/LinearAlgebra/src/triangular.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,11 @@ Base.isstored(A::UpperTriangular, i::Int, j::Int) =
269269
@propagate_inbounds getindex(A::UpperTriangular, i::Int, j::Int) =
270270
i <= j ? A.data[i,j] : _zero(A.data,j,i)
271271

272+
_zero_triangular_half_str(::Type{<:UpperOrUnitUpperTriangular}) = "lower"
273+
_zero_triangular_half_str(::Type{<:LowerOrUnitLowerTriangular}) = "upper"
274+
272275
@noinline function throw_nonzeroerror(T, @nospecialize(x), i, j)
273-
_upper_lower_str(::Type{<:UpperOrUnitUpperTriangular}) = "upper"
274-
_upper_lower_str(::Type{<:LowerOrUnitLowerTriangular}) = "lower"
275-
Ts = _upper_lower_str(T)
276+
Ts = _zero_triangular_half_str(T)
276277
Tn = nameof(T)
277278
throw(ArgumentError(
278279
lazy"cannot set index in the $Ts triangular part ($i, $j) of an $Tn matrix to a nonzero value ($x)"))
@@ -324,9 +325,7 @@ end
324325
end
325326

326327
@noinline function throw_setindex_structuralzero_error(T, @nospecialize(x))
327-
_struct_zero_half_str(::Type{<:UpperTriangular}) = "lower"
328-
_struct_zero_half_str(::Type{<:LowerTriangular}) = "upper"
329-
Ts = _struct_zero_half_str(T)
328+
Ts = _zero_triangular_half_str(T)
330329
Tn = nameof(T)
331330
throw(ArgumentError(
332331
lazy"cannot set indices in the $Ts triangular part of an $Tn matrix to a nonzero value ($x)"))

0 commit comments

Comments
 (0)