all: Combine sequential appends (#8461)

This commit is contained in:
Jakob Borg
2022-07-28 17:28:24 +02:00
committed by GitHub
parent f3835122bb
commit 388e4db9cd
2 changed files with 60 additions and 78 deletions
+14 -33
View File
@@ -785,72 +785,53 @@ func getReport(db *sql.DB) map[string]interface{} {
} }
} }
var categories []category categories := []category{
categories = append(categories, category{ {
Values: statsForInts(totFiles), Values: statsForInts(totFiles),
Descr: "Files Managed per Device", Descr: "Files Managed per Device",
}) }, {
categories = append(categories, category{
Values: statsForInts(maxFiles), Values: statsForInts(maxFiles),
Descr: "Files in Largest Folder", Descr: "Files in Largest Folder",
}) }, {
categories = append(categories, category{
Values: statsForInt64s(totMiB), Values: statsForInt64s(totMiB),
Descr: "Data Managed per Device", Descr: "Data Managed per Device",
Unit: "B", Unit: "B",
Type: NumberBinary, Type: NumberBinary,
}) }, {
categories = append(categories, category{
Values: statsForInt64s(maxMiB), Values: statsForInt64s(maxMiB),
Descr: "Data in Largest Folder", Descr: "Data in Largest Folder",
Unit: "B", Unit: "B",
Type: NumberBinary, Type: NumberBinary,
}) }, {
categories = append(categories, category{
Values: statsForInts(numDevices), Values: statsForInts(numDevices),
Descr: "Number of Devices in Cluster", Descr: "Number of Devices in Cluster",
}) }, {
categories = append(categories, category{
Values: statsForInts(numFolders), Values: statsForInts(numFolders),
Descr: "Number of Folders Configured", Descr: "Number of Folders Configured",
}) }, {
categories = append(categories, category{
Values: statsForInt64s(memoryUsage), Values: statsForInt64s(memoryUsage),
Descr: "Memory Usage", Descr: "Memory Usage",
Unit: "B", Unit: "B",
Type: NumberBinary, Type: NumberBinary,
}) }, {
categories = append(categories, category{
Values: statsForInt64s(memorySize), Values: statsForInt64s(memorySize),
Descr: "System Memory", Descr: "System Memory",
Unit: "B", Unit: "B",
Type: NumberBinary, Type: NumberBinary,
}) }, {
categories = append(categories, category{
Values: statsForFloats(sha256Perf), Values: statsForFloats(sha256Perf),
Descr: "SHA-256 Hashing Performance", Descr: "SHA-256 Hashing Performance",
Unit: "B/s", Unit: "B/s",
Type: NumberBinary, Type: NumberBinary,
}) }, {
categories = append(categories, category{
Values: statsForInts(numCPU), Values: statsForInts(numCPU),
Descr: "Number of CPU cores", Descr: "Number of CPU cores",
}) }, {
categories = append(categories, category{
Values: statsForInts(uptime), Values: statsForInts(uptime),
Descr: "Uptime (v3)", Descr: "Uptime (v3)",
Type: NumberDuration, Type: NumberDuration,
}) },
}
reportFeatures := make(map[string][]feature) reportFeatures := make(map[string][]feature)
for featureType, versions := range features { for featureType, versions := range features {
+4 -3
View File
@@ -80,12 +80,13 @@ func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protoco
if !pullerVersion.Equal(localFile.version) || !pullerCreated.Equal(localFile.created) { if !pullerVersion.Equal(localFile.version) || !pullerCreated.Equal(localFile.created) {
// The version has changed or the puller was reconstrcuted due to failure. // The version has changed or the puller was reconstrcuted due to failure.
// Clean up whatever we had for the old file, and advertise the new file. // Clean up whatever we had for the old file, and advertise the new file.
updates = append(updates, protocol.FileDownloadProgressUpdate{ updates = append(updates,
protocol.FileDownloadProgressUpdate{
Name: name, Name: name,
Version: localFile.version, Version: localFile.version,
UpdateType: protocol.FileDownloadProgressUpdateTypeForget, UpdateType: protocol.FileDownloadProgressUpdateTypeForget,
}) },
updates = append(updates, protocol.FileDownloadProgressUpdate{ protocol.FileDownloadProgressUpdate{
Name: name, Name: name,
Version: pullerVersion, Version: pullerVersion,
UpdateType: protocol.FileDownloadProgressUpdateTypeAppend, UpdateType: protocol.FileDownloadProgressUpdateTypeAppend,