mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Always inline some strbuf methods
This commit is contained in:
+6
-2
@@ -256,9 +256,14 @@ if(LINUX OR ANDROID)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(LINUX OR BSD)
|
||||
if(LINUX OR ANDROID OR BSD)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/detection/cpuUsage/cpuUsage_linux.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if(LINUX OR BSD)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/detection/host/host_linux.c
|
||||
src/detection/os/os_linux.c
|
||||
src/detection/gpu/gpu_linux.c
|
||||
@@ -299,7 +304,6 @@ endif()
|
||||
|
||||
if(ANDROID)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/detection/cpuUsage/cpuUsage_linux.c
|
||||
src/detection/host/host_android.c
|
||||
src/detection/os/os_android.c
|
||||
src/detection/gpu/gpu_android.c
|
||||
|
||||
+1
-1
@@ -1433,7 +1433,7 @@ int main(int argc, const char** argv)
|
||||
|
||||
//If we don't have a custom structure, use the default one
|
||||
if(data.structure.length == 0)
|
||||
ffStrbufSetS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE);
|
||||
ffStrbufAppendS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE);
|
||||
|
||||
ffStart(&instance);
|
||||
|
||||
|
||||
@@ -21,4 +21,10 @@
|
||||
#define FF_C_SCANF(formatStrIndex, argsStartIndex)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define FF_C_INLINE __attribute__((always_inline)) static inline
|
||||
#else
|
||||
#define FF_C_INLINE static inline
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+7
-22
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
static char* CHAR_NULL_PTR = "";
|
||||
@@ -29,12 +28,6 @@ void ffStrbufInitCopy(FFstrbuf* strbuf, const FFstrbuf* src)
|
||||
ffStrbufAppend(strbuf, src);
|
||||
}
|
||||
|
||||
void ffStrbufInitS(FFstrbuf* strbuf, const char* str)
|
||||
{
|
||||
ffStrbufInitA(strbuf, 0);
|
||||
ffStrbufAppendS(strbuf, str);
|
||||
}
|
||||
|
||||
uint32_t ffStrbufGetFree(const FFstrbuf* strbuf)
|
||||
{
|
||||
if(strbuf->allocated == 0)
|
||||
@@ -50,7 +43,7 @@ void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free)
|
||||
|
||||
uint32_t allocate = strbuf->allocated;
|
||||
if(allocate < 2)
|
||||
allocate = 2;
|
||||
allocate = FASTFETCH_STRBUF_DEFAULT_ALLOC;
|
||||
|
||||
while((strbuf->length + free + 1) > allocate) // + 1 for the null byte
|
||||
allocate *= 2;
|
||||
@@ -95,14 +88,6 @@ void ffStrbufAppendC(FFstrbuf* strbuf, char c)
|
||||
strbuf->chars[strbuf->length] = '\0';
|
||||
}
|
||||
|
||||
void ffStrbufAppendS(FFstrbuf* strbuf, const char* value)
|
||||
{
|
||||
if(value == NULL)
|
||||
return;
|
||||
|
||||
ffStrbufAppendNS(strbuf, (uint32_t)strlen(value), value);
|
||||
}
|
||||
|
||||
void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value)
|
||||
{
|
||||
if(value == NULL)
|
||||
@@ -194,18 +179,18 @@ void ffStrbufPrependNS(FFstrbuf* strbuf, uint32_t length, const char* value)
|
||||
strbuf->length += length;
|
||||
}
|
||||
|
||||
void ffStrbufSetNS(FFstrbuf* strbuf, uint32_t length, const char* value)
|
||||
{
|
||||
ffStrbufClear(strbuf);
|
||||
ffStrbufAppendNS(strbuf, length, value);
|
||||
}
|
||||
|
||||
void ffStrbufSet(FFstrbuf* strbuf, const FFstrbuf* value)
|
||||
{
|
||||
ffStrbufClear(strbuf);
|
||||
ffStrbufAppendNS(strbuf, value->length, value->chars);
|
||||
}
|
||||
|
||||
void ffStrbufSetS(FFstrbuf* strbuf, const char* value)
|
||||
{
|
||||
ffStrbufClear(strbuf);
|
||||
ffStrbufAppendS(strbuf, value);
|
||||
}
|
||||
|
||||
int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp)
|
||||
{
|
||||
if(strbuf->length != comp->length)
|
||||
|
||||
+24
-3
@@ -9,6 +9,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define FASTFETCH_STRBUF_DEFAULT_ALLOC 32
|
||||
|
||||
@@ -24,7 +25,13 @@ typedef struct FFstrbuf
|
||||
void ffStrbufInit(FFstrbuf* strbuf);
|
||||
void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate);
|
||||
void ffStrbufInitCopy(FFstrbuf* strbuf, const FFstrbuf* src);
|
||||
void ffStrbufInitS(FFstrbuf* strbuf, const char* str);
|
||||
|
||||
FF_C_INLINE void ffStrbufAppendS(FFstrbuf* strbuf, const char* value);
|
||||
FF_C_INLINE void ffStrbufInitS(FFstrbuf* strbuf, const char* str)
|
||||
{
|
||||
ffStrbufInitA(strbuf, 0);
|
||||
ffStrbufAppendS(strbuf, str);
|
||||
}
|
||||
|
||||
void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free);
|
||||
|
||||
@@ -36,8 +43,16 @@ void ffStrbufRecalculateLength(FFstrbuf* strbuf);
|
||||
|
||||
void ffStrbufAppend(FFstrbuf* strbuf, const FFstrbuf* value);
|
||||
void ffStrbufAppendC(FFstrbuf* strbuf, char c);
|
||||
void ffStrbufAppendS(FFstrbuf* strbuf, const char* value);
|
||||
|
||||
void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value);
|
||||
|
||||
FF_C_INLINE void ffStrbufAppendS(FFstrbuf* strbuf, const char* value)
|
||||
{
|
||||
if(value == NULL)
|
||||
return;
|
||||
ffStrbufAppendNS(strbuf, (uint32_t) strlen(value), value);
|
||||
}
|
||||
|
||||
void ffStrbufAppendNSExludingC(FFstrbuf* strbuf, uint32_t length, const char* value, char exclude);
|
||||
void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int(*transformFunc)(int));
|
||||
FF_C_PRINTF(2, 3) void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...);
|
||||
@@ -46,8 +61,14 @@ void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments);
|
||||
void ffStrbufPrependS(FFstrbuf* strbuf, const char* value);
|
||||
void ffStrbufPrependNS(FFstrbuf* strbuf, uint32_t length, const char* value);
|
||||
|
||||
void ffStrbufSetNS(FFstrbuf* strbuf, uint32_t length, const char* value);
|
||||
void ffStrbufSet(FFstrbuf* strbuf, const FFstrbuf* value);
|
||||
void ffStrbufSetS(FFstrbuf* strbuf, const char* value);
|
||||
|
||||
FF_C_INLINE void ffStrbufSetS(FFstrbuf* strbuf, const char* value)
|
||||
{
|
||||
ffStrbufClear(strbuf);
|
||||
ffStrbufAppendNS(strbuf, (uint32_t) strlen(value), value);
|
||||
}
|
||||
|
||||
FF_C_NODISCARD int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp);
|
||||
FF_C_NODISCARD int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp);
|
||||
|
||||
Reference in New Issue
Block a user