Parsing: simplify code

This commit is contained in:
李通洲
2023-07-27 15:17:54 +08:00
parent de3cb1f855
commit c9741d1662
6 changed files with 25 additions and 18 deletions
+2 -2
View File
@@ -28,10 +28,10 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
}
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
ffParseSize(disk->bytesUsed, instance.config.binaryPrefixType, &usedPretty);
ffParseSize(disk->bytesUsed, &usedPretty);
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
ffParseSize(disk->bytesTotal, instance.config.binaryPrefixType, &totalPretty);
ffParseSize(disk->bytesTotal, &totalPretty);
uint8_t bytesPercentage = disk->bytesTotal > 0 ? (uint8_t) (((long double) disk->bytesUsed / (long double) disk->bytesTotal) * 100.0) : 0;
+2 -2
View File
@@ -47,10 +47,10 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
{
ffParseSize(gpu->dedicated.used, instance.config.binaryPrefixType, &output);
ffParseSize(gpu->dedicated.used, &output);
ffStrbufAppendS(&output, " / ");
}
ffParseSize(gpu->dedicated.total, instance.config.binaryPrefixType, &output);
ffParseSize(gpu->dedicated.total, &output);
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
{
ffStrbufAppendS(&output, ", ");
+2 -2
View File
@@ -20,10 +20,10 @@ void ffPrintMemory(FFMemoryOptions* options)
}
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
ffParseSize(storage.bytesUsed, instance.config.binaryPrefixType, &usedPretty);
ffParseSize(storage.bytesUsed, &usedPretty);
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
ffParseSize(storage.bytesTotal, instance.config.binaryPrefixType, &totalPretty);
ffParseSize(storage.bytesTotal, &totalPretty);
uint8_t percentage = storage.bytesTotal == 0
? 0
+2 -2
View File
@@ -20,10 +20,10 @@ void ffPrintSwap(FFSwapOptions* options)
}
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
ffParseSize(storage.bytesUsed, instance.config.binaryPrefixType, &usedPretty);
ffParseSize(storage.bytesUsed, &usedPretty);
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
ffParseSize(storage.bytesTotal, instance.config.binaryPrefixType, &totalPretty);
ffParseSize(storage.bytesTotal, &totalPretty);
uint8_t percentage = storage.bytesTotal == 0
? 0