This commit is contained in:
blueloveTH 2024-06-15 17:56:36 +08:00
parent c98eb31a5e
commit 649fb3cd98
5 changed files with 26 additions and 45 deletions

View File

@ -1,16 +1,14 @@
# clang-format configuration # clang-format configuration
# compatible with clang-format 18 # compatible with clang-format 15
UseTab: Never UseTab: Never
ColumnLimit: 120 ColumnLimit: 100
# Indent # Indent
IndentWidth: 4 IndentWidth: 4
BracedInitializerIndentWidth: 4
AccessModifierOffset: -4 AccessModifierOffset: -4
IndentAccessModifiers: false IndentAccessModifiers: false
IndentCaseLabels: true IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: true IndentGotoLabels: true
IndentRequiresClause: true IndentRequiresClause: true
IndentWrappedFunctionNames: true IndentWrappedFunctionNames: true
@ -20,25 +18,18 @@ BitFieldColonSpacing: Both
# Insert # Insert
InsertBraces: false InsertBraces: false
InsertNewlineAtEOF: true
KeepEmptyLinesAtEOF: true
# Align # Align
AlignAfterOpenBracket: true AlignAfterOpenBracket: true
AlignTrailingComments:
Kind: Always
AlignArrayOfStructures: Left AlignArrayOfStructures: Left
PointerAlignment: Left PointerAlignment: Left
BreakAfterAttributes: Leave
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon BreakInheritanceList: AfterColon
BreakAdjacentStringLiterals: false
BreakStringLiterals: false BreakStringLiterals: false
CompactNamespaces: false CompactNamespaces: false
Cpp11BracedListStyle: true Cpp11BracedListStyle: true
@ -47,10 +38,8 @@ EmptyLineBeforeAccessModifier: Always
AllowAllArgumentsOnNextLine: false AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Always AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true AllowShortCaseLabelsOnASingleLine: true
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse AllowShortIfStatementsOnASingleLine: WithoutElse
@ -83,20 +72,12 @@ SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 2 SpacesBeforeTrailingComments: 2
SpacesInAngles: Never SpacesInAngles: Never
SpacesInParens: Custom
SpacesInParensOptions:
InConditionalStatements: false
InCStyleCasts: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
# Order # Order
QualifierAlignment: Custom QualifierAlignment: Custom
QualifierOrder: ["constexpr", "const", "inline", "static", "type"] QualifierOrder: ["constexpr", "const", "inline", "static", "type"]
SortIncludes: Never SortIncludes: Never
SortUsingDeclarations: LexicographicNumeric
IncludeBlocks: Merge IncludeBlocks: Merge
WhitespaceSensitiveMacros: ["PK_PROTECTED", "LUA_PROTECTED"] WhitespaceSensitiveMacros: ["PK_PROTECTED", "LUA_PROTECTED"]

View File

@ -10,12 +10,12 @@ extern "C" {
#define c11__lower_bound(T, ptr, count, key, less, out) \ #define c11__lower_bound(T, ptr, count, key, less, out) \
do { \ do { \
const T *__first = ptr; \ T* __first = ptr; \
int __len = count; \ int __len = count; \
while (__len != 0) { \ while(__len != 0) { \
int __l2 = (int)((unsigned int)__len / 2); \ int __l2 = (int)((unsigned int)__len / 2); \
const T *__m = __first + __l2; \ T* __m = __first + __l2; \
if (less((*__m), (key))) { \ if(less((*__m), (key))) { \
__first = ++__m; \ __first = ++__m; \
__len -= __l2 + 1; \ __len -= __l2 + 1; \
} else { \ } else { \
@ -23,7 +23,7 @@ extern "C" {
} \ } \
} \ } \
*(out) = __first; \ *(out) = __first; \
} while (0) } while(0)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -56,19 +56,19 @@ void c11_vector__clear(c11_vector* self);
}while(0) }while(0)
#define c11_vector__insert(T, self, index, elem) \ #define c11_vector__insert(T, self, p, elem) \
do{ \ do{ \
if((self)->count == (self)->capacity) c11_vector__reserve((self), (self)->capacity*2); \ if((self)->count == (self)->capacity) c11_vector__reserve((self), (self)->capacity*2); \
T* p = (T*)(self)->data + (index); \ int __n = (self)->count - (p - (T*)(self)->data); \
memmove(p + 1, p, ((self)->count - (index)) * sizeof(T)); \ memmove(p + 1, p, __n * sizeof(T)); \
*p = (elem); \ *p = (elem); \
(self)->count++; \ (self)->count++; \
}while(0) }while(0)
#define c11_vector__erase(T, self, index) \ #define c11_vector__erase(T, self, p) \
do{ \ do{ \
T* p = (T*)(self)->data + (index); \ int __n = (self)->count - (p - (T*)(self)->data) - 1; \
memmove(p, p + 1, ((self)->count - (index) - 1) * sizeof(T)); \ memmove(p, p + 1, __n * sizeof(T)); \
(self)->count--; \ (self)->count--; \
}while(0) }while(0)

View File

@ -387,7 +387,7 @@ static const int kLoRangeB[] = {170,186,443,451,660,1514,1522,1599,1610,1647,174
bool c11__is_unicode_Lo_char(int c){ bool c11__is_unicode_Lo_char(int c){
if(c == 0x1f955) return true; if(c == 0x1f955) return true;
const int* p; const int* p;
c11__lower_bound(int, kLoRangeA, 476, c, c11__less, &p); c11__lower_bound(const int, kLoRangeA, 476, c, c11__less, &p);
int index = p - kLoRangeA; int index = p - kLoRangeA;
if(c == kLoRangeA[index]) return true; if(c == kLoRangeA[index]) return true;
index -= 1; index -= 1;

View File

@ -199,7 +199,7 @@ struct Random {
List result(k); List result(k);
for(int i = 0; i < k; i++) { for(int i = 0; i < k; i++) {
f64 key = self.gen.uniform(0.0, cum_weights[size - 1]); f64 key = self.gen.uniform(0.0, cum_weights[size - 1]);
const f64* p; f64* p;
c11__lower_bound(f64, cum_weights.begin(), cum_weights.size(), key, c11__less, &p); c11__lower_bound(f64, cum_weights.begin(), cum_weights.size(), key, c11__less, &p);
result[i] = data[p - cum_weights.begin()]; result[i] = data[p - cum_weights.begin()];
} }