Skip to content

Commit a782d47

Browse files
committed
Avoid copy in twist for tensors with bosonic braiding
1 parent 9ba3b6c commit a782d47

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/tensors/indexmanipulations.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ If `inv=true`, use the inverse twist.
302302
303303
See [`twist!`](@ref) for storing the result in place.
304304
"""
305-
twist(t::AbstractTensorMap, i; inv::Bool = false) = twist!(copy(t), i; inv)
305+
function twist(t::AbstractTensorMap, i; inv::Bool = false)
306+
(BraidingStyle(sectortype(t)) == Bosonic() || isempty(is)) && return t
307+
return twist!(copy(t), i; inv)
308+
end
306309

307310
# Methods which change the number of indices, implement using `Val(i)` for type inference
308311
"""

0 commit comments

Comments
 (0)