Skip to content

Commit

Permalink
check coord set size more efficiently
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Nov 12, 2024
1 parent 6ee3a17 commit 6b1e606
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions syft/file/coordinate_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func (s CoordinateSet) ToSlice() []Coordinates {
return coordinates
}

func (s CoordinateSet) Size() int {
return len(s.set)
}

func (s CoordinateSet) Hash() (uint64, error) {
return hashstructure.Hash(s.ToSlice(), hashstructure.FormatV2, &hashstructure.HashOptions{
ZeroNil: true,
Expand Down
2 changes: 1 addition & 1 deletion syft/sbom/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s SBOM) AllCoordinates() []file.Coordinates {
for coordinates := range s.Artifacts.Unknowns {
set.Add(coordinates)
}
if len(set.ToSlice()) > 0 {
if set.Size() > 0 {
for _, relationship := range s.Relationships {
for _, coordinates := range extractCoordinates(relationship) {
set.Add(coordinates)
Expand Down

0 comments on commit 6b1e606

Please sign in to comment.