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

View File

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

View File

@ -56,19 +56,19 @@ void c11_vector__clear(c11_vector* self);
}while(0)
#define c11_vector__insert(T, self, index, elem) \
#define c11_vector__insert(T, self, p, elem) \
do{ \
if((self)->count == (self)->capacity) c11_vector__reserve((self), (self)->capacity*2); \
T* p = (T*)(self)->data + (index); \
memmove(p + 1, p, ((self)->count - (index)) * sizeof(T)); \
int __n = (self)->count - (p - (T*)(self)->data); \
memmove(p + 1, p, __n * sizeof(T)); \
*p = (elem); \
(self)->count++; \
}while(0)
#define c11_vector__erase(T, self, index) \
#define c11_vector__erase(T, self, p) \
do{ \
T* p = (T*)(self)->data + (index); \
memmove(p, p + 1, ((self)->count - (index) - 1) * sizeof(T)); \
int __n = (self)->count - (p - (T*)(self)->data) - 1; \
memmove(p, p + 1, __n * sizeof(T)); \
(self)->count--; \
}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){
if(c == 0x1f955) return true;
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;
if(c == kLoRangeA[index]) return true;
index -= 1;

View File

@ -199,7 +199,7 @@ struct Random {
List result(k);
for(int i = 0; i < k; i++) {
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);
result[i] = data[p - cum_weights.begin()];
}