Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ITensorBase"
uuid = "4795dd04-0d67-49bb-8f44-b89c448a1dc7"
version = "0.12.3"
version = "0.12.4"
authors = ["ITensor developers <support@itensor.org> and contributors"]

[workspace]
Expand Down
12 changes: 8 additions & 4 deletions src/index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,18 @@ Return the prime level of an index or index name: a non-negative integer raised
"""
plev(n::IndexName) = getfield(n, :plev)

# The tags dictionary is the only costly field to compare, so short-circuit it with `===`:
# a name reused across tensors carries the same tags object and skips the dictionary walk.
function Base.:(==)(n1::IndexName, n2::IndexName)
return uuid(n1) == uuid(n2) && plev(n1) == plev(n2) &&
tags_stored(n1) == tags_stored(n2)
(tags_stored(n1) === tags_stored(n2) || tags_stored(n1) == tags_stored(n2))
end
function Base.isequal(n1::IndexName, n2::IndexName)
return isequal(uuid(n1), uuid(n2)) &&
isequal(plev(n1), plev(n2)) &&
isequal(tags_stored(n1), tags_stored(n2))
return isequal(uuid(n1), uuid(n2)) && isequal(plev(n1), plev(n2)) &&
(
tags_stored(n1) === tags_stored(n2) ||
isequal(tags_stored(n1), tags_stored(n2))
)
end
function Base.isless(n1::IndexName, n2::IndexName)
t1 = (uuid(n1), plev(n1), keys(tags_stored(n1)), values(tags_stored(n1)))
Expand Down