mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
Global: adds some always_inline
This commit is contained in:
+17
-25
@@ -40,6 +40,7 @@ HANDLE openat(HANDLE dfd, const char* fileName, int oflag);
|
||||
HANDLE openatW(HANDLE dfd, const wchar_t* fileName, uint16_t fileNameLen, bool directory);
|
||||
#endif
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffIsValidNativeFD(FFNativeFD fd) {
|
||||
#ifndef _WIN32
|
||||
return fd >= 0;
|
||||
@@ -49,20 +50,17 @@ static inline bool ffIsValidNativeFD(FFNativeFD fd) {
|
||||
#endif
|
||||
}
|
||||
|
||||
FF_A_NONNULL(1) static inline bool wrapClose(FFNativeFD* pfd) {
|
||||
FF_A_ALWAYS_INLINE FF_A_NONNULL(1)
|
||||
static inline void wrapClose(FFNativeFD* pfd) {
|
||||
assert(pfd);
|
||||
|
||||
if (!ffIsValidNativeFD(*pfd)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ffIsValidNativeFD(*pfd)) {
|
||||
#ifndef _WIN32
|
||||
close(*pfd);
|
||||
close(*pfd);
|
||||
#else
|
||||
NtClose(*pfd);
|
||||
NtClose(*pfd);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#define FF_AUTO_CLOSE_FD FF_A_CLEANUP(wrapClose)
|
||||
|
||||
@@ -250,34 +248,28 @@ static inline void ffUnsuppressIO(bool* suppressed) {
|
||||
|
||||
void ffListFilesRecursively(const char* path, bool pretty);
|
||||
|
||||
FF_A_NONNULL(1) static inline bool wrapFclose(FILE** pfile) {
|
||||
FF_A_NONNULL(1) FF_A_ALWAYS_INLINE static inline void wrapFclose(FILE** pfile) {
|
||||
assert(pfile);
|
||||
if (!*pfile) {
|
||||
return false;
|
||||
if (*pfile) {
|
||||
fclose(*pfile);
|
||||
}
|
||||
fclose(*pfile);
|
||||
return true;
|
||||
}
|
||||
#define FF_AUTO_CLOSE_FILE FF_A_CLEANUP(wrapFclose)
|
||||
|
||||
FF_A_NONNULL(1)
|
||||
FF_A_NONNULL(1) FF_A_ALWAYS_INLINE
|
||||
#ifndef _WIN32
|
||||
static inline bool wrapClosedir(DIR** pdir) {
|
||||
static inline void wrapClosedir(DIR** pdir) {
|
||||
assert(pdir);
|
||||
if (!*pdir) {
|
||||
return false;
|
||||
if (*pdir) {
|
||||
closedir(*pdir);
|
||||
}
|
||||
closedir(*pdir);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
static inline bool wrapClosedir(HANDLE* pdir) {
|
||||
static inline void wrapClosedir(HANDLE* pdir) {
|
||||
assert(pdir);
|
||||
if (!*pdir) {
|
||||
return false;
|
||||
if (*pdir) {
|
||||
FindClose(*pdir);
|
||||
}
|
||||
FindClose(*pdir);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#define FF_AUTO_CLOSE_DIR FF_A_CLEANUP(wrapClosedir)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "common/attributes.h"
|
||||
|
||||
#if FF_HAVE_MALLOC_USABLE_SIZE || FF_HAVE_MSVC_MSIZE
|
||||
#if __has_include(<malloc.h>)
|
||||
@@ -13,6 +14,7 @@
|
||||
#include <malloc/malloc.h>
|
||||
#endif
|
||||
|
||||
FF_A_ALWAYS_INLINE FF_A_NONNULL(1)
|
||||
static inline void ffWrapFree(const void* pPtr) {
|
||||
assert(pPtr);
|
||||
if (*(void**) pPtr) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "common/attributes.h"
|
||||
#include "common/wcwidth.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -25,14 +26,17 @@ static inline bool ffStrSet(const char* str) {
|
||||
return *str != '\0';
|
||||
}
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffStrStartsWithIgnCase(const char* str, const char* compareTo) {
|
||||
return strncasecmp(str, compareTo, strlen(compareTo)) == 0;
|
||||
}
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffStrEqualsIgnCase(const char* str, const char* compareTo) {
|
||||
return strcasecmp(str, compareTo) == 0;
|
||||
}
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffStrStartsWith(const char* str, const char* compareTo) {
|
||||
return strncmp(str, compareTo, strlen(compareTo)) == 0;
|
||||
}
|
||||
@@ -55,26 +59,32 @@ static inline bool ffStrEndsWithIgnCase(const char* str, const char* compareTo)
|
||||
return strncasecmp(str + strLength - compareToLength, compareTo, compareToLength) == 0;
|
||||
}
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffStrEquals(const char* str, const char* compareTo) {
|
||||
return strcmp(str, compareTo) == 0;
|
||||
}
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffStrContains(const char* str, const char* compareTo) {
|
||||
return strstr(str, compareTo) != NULL;
|
||||
}
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffStrContainsIgnCase(const char* str, const char* compareTo) {
|
||||
return strcasestr(str, compareTo) != NULL;
|
||||
}
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffStrContainsC(const char* str, char compareTo) {
|
||||
return strchr(str, compareTo) != NULL;
|
||||
}
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffCharIsEnglishAlphabet(char c) {
|
||||
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
|
||||
}
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffCharIsDigit(char c) {
|
||||
return '0' <= c && c <= '9';
|
||||
}
|
||||
@@ -86,6 +96,7 @@ uint8_t ffUtf8CharLenWidth(const char* str, uint32_t length, uint8_t* width);
|
||||
|
||||
uint32_t ffUtf8StrWidth(const char* str, uint32_t length);
|
||||
|
||||
FF_A_ALWAYS_INLINE
|
||||
static inline bool ffCharIsHexDigit(char c) {
|
||||
return ffCharIsDigit(c) || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user