More style improvements

This commit is contained in:
gingerBill
2024-06-29 19:07:34 +01:00
parent e8517e2694
commit 3f9a58808c
6 changed files with 37 additions and 61 deletions
+1 -2
View File
@@ -70,8 +70,7 @@ set :: proc(c: ^$C/Cache($Key, $Value), key: Key, value: Value) -> runtime.Alloc
if c.count == c.capacity {
e = c.tail
_remove_node(c, e)
}
else {
} else {
c.count += 1
e = new(Node(Key, Value), c.node_allocator) or_return
}
+11 -10
View File
@@ -897,19 +897,20 @@ XXH3_hashLong_64b_default :: #force_no_inline proc(input: []u8, seed64: xxh_u64,
why (uop cache maybe?), but the difference is large and easily measurable.
*/
@(optimization_mode="speed")
XXH3_hashLong_64b_withSeed_internal :: #force_no_inline proc(input: []u8,
seed: xxh_u64,
f_acc512: XXH3_accumulate_512_f,
f_scramble: XXH3_scramble_accumulator_f,
f_init_sec: XXH3_init_custom_secret_f) -> (hash: xxh_u64) {
XXH3_hashLong_64b_withSeed_internal :: #force_no_inline proc(
input: []u8,
seed: xxh_u64,
f_acc512: XXH3_accumulate_512_f,
f_scramble: XXH3_scramble_accumulator_f,
f_init_sec: XXH3_init_custom_secret_f,
) -> (hash: xxh_u64) {
if seed == 0 {
return XXH3_hashLong_64b_internal(input, XXH3_kSecret[:], f_acc512, f_scramble)
}
{
secret: [XXH_SECRET_DEFAULT_SIZE]u8
f_init_sec(secret[:], seed)
return XXH3_hashLong_64b_internal(input, secret[:], f_acc512, f_scramble)
}
secret: [XXH_SECRET_DEFAULT_SIZE]u8
f_init_sec(secret[:], seed)
return XXH3_hashLong_64b_internal(input, secret[:], f_acc512, f_scramble)
}
/*
+1 -1
View File
@@ -655,7 +655,7 @@ choice_enum :: proc($T: typeid) -> T
where
intrinsics.type_is_enum(T),
size_of(T) <= 8,
len(T) == cap(T) /* Only allow contiguous enum types */
len(T) == cap(T) /* Only allow contiguous enum types */ \
{
when intrinsics.type_is_unsigned(intrinsics.type_core_type(T)) &&
u64(max(T)) > u64(max(i64)) {
+1 -2
View File
@@ -156,8 +156,7 @@ linear_search_proc :: proc(array: $A/[]$T, f: proc(T) -> bool) -> (index: int, f
*/
@(require_results)
binary_search :: proc(array: $A/[]$T, key: T) -> (index: int, found: bool)
where intrinsics.type_is_ordered(T) #no_bounds_check
{
where intrinsics.type_is_ordered(T) #no_bounds_check {
return binary_search_by(array, key, cmp_proc(T))
}
+9 -18
View File
@@ -240,8 +240,7 @@ decode_grapheme_clusters :: proc(
// GB8: (LVT | T) × T
if is_hangul_syllable_leading(this_rune) ||
is_hangul_syllable_lv(this_rune) ||
is_hangul_syllable_lvt(this_rune)
{
is_hangul_syllable_lvt(this_rune) {
if !is_hangul_syllable_leading(last_rune) {
grapheme_count += 1
}
@@ -251,8 +250,7 @@ decode_grapheme_clusters :: proc(
if is_hangul_syllable_vowel(this_rune) {
if is_hangul_syllable_leading(last_rune) ||
is_hangul_syllable_vowel(last_rune) ||
is_hangul_syllable_lv(last_rune)
{
is_hangul_syllable_lv(last_rune) {
continue
}
grapheme_count += 1
@@ -263,8 +261,7 @@ decode_grapheme_clusters :: proc(
if is_hangul_syllable_trailing(last_rune) ||
is_hangul_syllable_lvt(last_rune) ||
is_hangul_syllable_lv(last_rune) ||
is_hangul_syllable_vowel(last_rune)
{
is_hangul_syllable_vowel(last_rune) {
continue
}
grapheme_count += 1
@@ -285,8 +282,7 @@ decode_grapheme_clusters :: proc(
if current_sequence == .Indic {
if is_indic_conjunct_break_extend(this_rune) && (
is_indic_conjunct_break_linker(last_rune) ||
is_indic_conjunct_break_consonant(last_rune) )
{
is_indic_conjunct_break_consonant(last_rune) ) {
continue_sequence = true
continue
}
@@ -294,8 +290,7 @@ decode_grapheme_clusters :: proc(
if is_indic_conjunct_break_linker(this_rune) && (
is_indic_conjunct_break_linker(last_rune) ||
is_indic_conjunct_break_extend(last_rune) ||
is_indic_conjunct_break_consonant(last_rune) )
{
is_indic_conjunct_break_consonant(last_rune) ) {
continue_sequence = true
continue
}
@@ -306,8 +301,7 @@ decode_grapheme_clusters :: proc(
// (Support for GB11.)
if current_sequence == .Emoji && (
is_gcb_extend_class(last_rune) ||
is_emoji_extended_pictographic(last_rune) )
{
is_emoji_extended_pictographic(last_rune) ) {
continue_sequence = true
}
@@ -336,8 +330,7 @@ decode_grapheme_clusters :: proc(
if is_indic_conjunct_break_consonant(this_rune) {
if current_sequence == .Indic {
if last_rune == ZERO_WIDTH_JOINER ||
is_indic_conjunct_break_linker(last_rune)
{
is_indic_conjunct_break_linker(last_rune) {
continue_sequence = true
} else {
grapheme_count += 1
@@ -353,8 +346,7 @@ decode_grapheme_clusters :: proc(
if is_indic_conjunct_break_extend(this_rune) {
if current_sequence == .Indic {
if is_indic_conjunct_break_consonant(last_rune) ||
is_indic_conjunct_break_linker(last_rune)
{
is_indic_conjunct_break_linker(last_rune) {
continue_sequence = true
} else {
grapheme_count += 1
@@ -366,8 +358,7 @@ decode_grapheme_clusters :: proc(
if is_indic_conjunct_break_linker(this_rune) {
if current_sequence == .Indic {
if is_indic_conjunct_break_extend(last_rune) ||
is_indic_conjunct_break_linker(last_rune)
{
is_indic_conjunct_break_linker(last_rune) {
continue_sequence = true
} else {
grapheme_count += 1
+14 -28
View File
@@ -454,20 +454,13 @@ when !GL_DEBUG {
BeginQueryIndexed :: proc "c" (target: u32, index: u32, id: u32) { impl_BeginQueryIndexed(target, index, id) }
EndQueryIndexed :: proc "c" (target: u32, index: u32) { impl_EndQueryIndexed(target, index) }
GetQueryIndexediv :: proc "c" (target: u32, index: u32, pname: u32, params: [^]i32) { impl_GetQueryIndexediv(target, index, pname, params) }
GetTextureHandleARB :: proc "c" (texture: u32) -> u64
{ return impl_GetTextureHandleARB(texture) }
GetTextureSamplerHandleARB :: proc "c" (texture, sampler: u32) -> u64
{ return impl_GetTextureSamplerHandleARB(texture, sampler) }
GetImageHandleARB :: proc "c" (texture: u32, level: i32, layered: bool, layer: i32, format: u32) -> u64
{ return impl_GetImageHandleARB(texture, level, layered, layer, format) }
MakeTextureHandleResidentARB :: proc "c" (handle: u64)
{ impl_MakeTextureHandleResidentARB(handle) }
MakeImageHandleResidentARB :: proc "c" (handle: u64, access: u32)
{ impl_MakeImageHandleResidentARB(handle, access) }
MakeTextureHandleNonResidentARB:: proc "c" (handle: u64)
{ impl_MakeTextureHandleNonResidentARB(handle) }
MakeImageHandleNonResidentARB :: proc "c" (handle: u64)
{ impl_MakeImageHandleNonResidentARB(handle) }
GetTextureHandleARB :: proc "c" (texture: u32) -> u64 { return impl_GetTextureHandleARB(texture) }
GetTextureSamplerHandleARB :: proc "c" (texture, sampler: u32) -> u64 { return impl_GetTextureSamplerHandleARB(texture, sampler) }
GetImageHandleARB :: proc "c" (texture: u32, level: i32, layered: bool, layer: i32, format: u32) -> u64 { return impl_GetImageHandleARB(texture, level, layered, layer, format) }
MakeTextureHandleResidentARB :: proc "c" (handle: u64) { impl_MakeTextureHandleResidentARB(handle) }
MakeImageHandleResidentARB :: proc "c" (handle: u64, access: u32) { impl_MakeImageHandleResidentARB(handle, access) }
MakeTextureHandleNonResidentARB:: proc "c" (handle: u64) { impl_MakeTextureHandleNonResidentARB(handle) }
MakeImageHandleNonResidentARB :: proc "c" (handle: u64) { impl_MakeImageHandleNonResidentARB(handle) }
// VERSION_4_1
ReleaseShaderCompiler :: proc "c" () { impl_ReleaseShaderCompiler() }
@@ -1265,20 +1258,13 @@ when !GL_DEBUG {
BeginQueryIndexed :: proc "c" (target: u32, index: u32, id: u32, loc := #caller_location) { impl_BeginQueryIndexed(target, index, id); debug_helper(loc, 0, target, index, id) }
EndQueryIndexed :: proc "c" (target: u32, index: u32, loc := #caller_location) { impl_EndQueryIndexed(target, index); debug_helper(loc, 0, target, index) }
GetQueryIndexediv :: proc "c" (target: u32, index: u32, pname: u32, params: [^]i32, loc := #caller_location) { impl_GetQueryIndexediv(target, index, pname, params); debug_helper(loc, 0, target, index, pname, params) }
GetTextureHandleARB :: proc "c" (target: u32, loc := #caller_location) -> u64
{ ret := impl_GetTextureHandleARB(target); debug_helper(loc, 0, target); return ret }
GetTextureSamplerHandleARB :: proc "c" (texture, sampler: u32, loc := #caller_location) -> u64
{ ret := impl_GetTextureSamplerHandleARB(texture, sampler); debug_helper(loc, 0, texture, sampler); return ret }
GetImageHandleARB :: proc "c" (texture: u32, level: i32, layered: bool, layer: i32, format: u32, loc := #caller_location) -> u64
{ ret := impl_GetImageHandleARB(texture, level, layered, layer, format); debug_helper(loc, 0, texture, level, layered, layer, format); return ret }
MakeTextureHandleResidentARB :: proc "c" (handle: u64, loc := #caller_location)
{ impl_MakeTextureHandleResidentARB(handle); debug_helper(loc, 0, handle) }
MakeImageHandleResidentARB :: proc "c" (handle: u64, access: u32, loc := #caller_location)
{ impl_MakeImageHandleResidentARB(handle, access); debug_helper(loc, 0, handle, access) }
MakeTextureHandleNonResidentARB:: proc "c" (handle: u64, loc := #caller_location)
{ impl_MakeTextureHandleNonResidentARB(handle); debug_helper(loc, 0, handle) }
MakeImageHandleNonResidentARB :: proc "c" (handle: u64, loc := #caller_location)
{ impl_MakeImageHandleNonResidentARB(handle); debug_helper(loc, 0, handle) }
GetTextureHandleARB :: proc "c" (target: u32, loc := #caller_location) -> u64 { ret := impl_GetTextureHandleARB(target); debug_helper(loc, 0, target); return ret }
GetTextureSamplerHandleARB :: proc "c" (texture, sampler: u32, loc := #caller_location) -> u64 { ret := impl_GetTextureSamplerHandleARB(texture, sampler); debug_helper(loc, 0, texture, sampler); return ret }
GetImageHandleARB :: proc "c" (texture: u32, level: i32, layered: bool, layer: i32, format: u32, loc := #caller_location) -> u64 { ret := impl_GetImageHandleARB(texture, level, layered, layer, format); debug_helper(loc, 0, texture, level, layered, layer, format); return ret }
MakeTextureHandleResidentARB :: proc "c" (handle: u64, loc := #caller_location) { impl_MakeTextureHandleResidentARB(handle); debug_helper(loc, 0, handle) }
MakeImageHandleResidentARB :: proc "c" (handle: u64, access: u32, loc := #caller_location) { impl_MakeImageHandleResidentARB(handle, access); debug_helper(loc, 0, handle, access) }
MakeTextureHandleNonResidentARB:: proc "c" (handle: u64, loc := #caller_location) { impl_MakeTextureHandleNonResidentARB(handle); debug_helper(loc, 0, handle) }
MakeImageHandleNonResidentARB :: proc "c" (handle: u64, loc := #caller_location) { impl_MakeImageHandleNonResidentARB(handle); debug_helper(loc, 0, handle) }