Skip to content

Commit

Permalink
Rename variables again.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Wurm committed Feb 5, 2019
1 parent 02b5dd2 commit c4b3197
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions x-pack/auditbeat/module/system/package/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,18 @@ func (ms *MetricSet) reportChanges(report mb.ReporterV2) error {
ms.log.Debugf("Found %v packages", len(packages))

newInCache, missingFromCache := ms.cache.DiffAndUpdateCache(convertToCacheable(packages))
new := convertToPackage(newInCache)
missing := convertToPackage(missingFromCache)
newPackages := convertToPackage(newInCache)
missingPackages := convertToPackage(missingFromCache)

// Package names of updated packages
updated := make(map[string]struct{})

for _, missingPkg := range missing {
for _, missingPkg := range missingPackages {
found := false

// Using an inner loop is less efficient than using a map, but in this case
// we do not expect a lot of installed or removed packages all at once.
for _, newPkg := range new {
for _, newPkg := range newPackages {
if missingPkg.Name == newPkg.Name {
found = true
updated[newPkg.Name] = struct{}{}
Expand All @@ -337,13 +337,13 @@ func (ms *MetricSet) reportChanges(report mb.ReporterV2) error {
}
}

for _, newPkg := range new {
for _, newPkg := range newPackages {
if _, contains := updated[newPkg.Name]; !contains {
report.Event(packageEvent(newPkg, eventTypeEvent, eventActionPackageInstalled))
}
}

if len(new) > 0 || len(missing) > 0 {
if len(newPackages) > 0 || len(missingPackages) > 0 {
return ms.savePackagesToDisk(packages)
}

Expand Down

0 comments on commit c4b3197

Please sign in to comment.