Skip to content

Commit

Permalink
chore: impact only calc the referenced
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfzc committed Aug 14, 2023
1 parent 0dcf086 commit 5268463
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
19 changes: 8 additions & 11 deletions graph/file/api_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ func (fg *Graph) Stat(f *Vertex) *object.ImpactUnit {
impactUnit.FileName = f.Path
impactUnit.UnitName = f.Id()

impactUnit.ImpactCount = len(referencedIds) + len(referenceIds)
impactUnit.TransImpactCount = len(transitiveReferenceIds) + len(transitiveReferencedIds)

impactUnit.ImpactCount = len(referencedIds)
impactUnit.TransImpactCount = len(transitiveReferencedIds)
impactUnit.ImpactEntries = len(entries)

// details
Expand Down Expand Up @@ -70,10 +69,9 @@ func (fg *Graph) GlobalStat(points []*Vertex) *object.StatGlobal {
eachId := sg.UnitMapping[eachReferenced]
directImpactMap[eachId] = struct{}{}
}
for _, eachReference := range each.ReferenceIds {
eachId := sg.UnitMapping[eachReference]
directImpactMap[eachId] = struct{}{}
}
// and itself
itselfId := sg.UnitMapping[each.Self.Id()]
directImpactMap[itselfId] = struct{}{}
}
directImpactList := make([]int, 0, len(directImpactMap))
for each := range directImpactMap {
Expand All @@ -88,10 +86,9 @@ func (fg *Graph) GlobalStat(points []*Vertex) *object.StatGlobal {
eachId := sg.UnitMapping[eachReferenced]
indirectImpactMap[eachId] = struct{}{}
}
for _, eachReference := range each.TransitiveReferenceIds {
eachId := sg.UnitMapping[eachReference]
indirectImpactMap[eachId] = struct{}{}
}
// and itself
itselfId := sg.UnitMapping[each.Self.Id()]
indirectImpactMap[itselfId] = struct{}{}
}
indirectImpactList := make([]int, 0, len(indirectImpactMap))
for each := range indirectImpactMap {
Expand Down
15 changes: 5 additions & 10 deletions graph/function/api_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func (fg *Graph) Stat(f *Vertex) *object.ImpactUnit {
impactUnit.FileName = f.Path
impactUnit.UnitName = f.Id()

impactUnit.ImpactCount = len(referencedIds) + len(referenceIds)
impactUnit.TransImpactCount = len(transitiveReferenceIds) + len(transitiveReferencedIds)
impactUnit.ImpactCount = len(referencedIds)
impactUnit.TransImpactCount = len(transitiveReferencedIds)
impactUnit.ImpactEntries = len(entries)

// details
Expand Down Expand Up @@ -66,10 +66,6 @@ func (fg *Graph) GlobalStat(points []*Vertex) *object.StatGlobal {
eachId := sg.UnitMapping[eachReferenced]
directImpactMap[eachId] = struct{}{}
}
for _, eachReference := range each.ReferenceIds {
eachId := sg.UnitMapping[eachReference]
directImpactMap[eachId] = struct{}{}
}
// and itself
itselfId := sg.UnitMapping[each.Self.Id()]
directImpactMap[itselfId] = struct{}{}
Expand All @@ -87,10 +83,9 @@ func (fg *Graph) GlobalStat(points []*Vertex) *object.StatGlobal {
eachId := sg.UnitMapping[eachReferenced]
indirectImpactMap[eachId] = struct{}{}
}
for _, eachReference := range each.TransitiveReferenceIds {
eachId := sg.UnitMapping[eachReference]
indirectImpactMap[eachId] = struct{}{}
}
// and itself
itselfId := sg.UnitMapping[each.Self.Id()]
indirectImpactMap[itselfId] = struct{}{}
}
indirectImpactList := make([]int, 0, len(indirectImpactMap))
for each := range indirectImpactMap {
Expand Down

0 comments on commit 5268463

Please sign in to comment.