mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Reduce number of range and slice operators #239
Replace .. and ... with : and ..
This commit is contained in:
@@ -350,7 +350,7 @@ delete_key :: proc(m: ^$T/map[$K]$V, key: K) {
|
||||
|
||||
|
||||
@(builtin)
|
||||
append :: proc(array: ^$T/[dynamic]$E, args: ...E, loc := #caller_location) -> int {
|
||||
append :: proc(array: ^$T/[dynamic]$E, args: ..E, loc := #caller_location) -> int {
|
||||
if array == nil do return 0;
|
||||
|
||||
arg_len := len(args);
|
||||
@@ -373,7 +373,7 @@ append :: proc(array: ^$T/[dynamic]$E, args: ...E, loc := #caller_location) -> i
|
||||
}
|
||||
|
||||
@(builtin)
|
||||
append_string :: proc(array: ^$T/[dynamic]$E/u8, args: ...string, loc := #caller_location) -> int {
|
||||
append_string :: proc(array: ^$T/[dynamic]$E/u8, args: ..string, loc := #caller_location) -> int {
|
||||
for arg in args {
|
||||
append(array = array, args = ([]E)(arg), loc = loc);
|
||||
}
|
||||
@@ -616,9 +616,9 @@ __dynamic_map_rehash :: proc(using header: Map_Header, new_count: int, loc := #c
|
||||
|
||||
__dynamic_array_resize(nm_hashes, size_of(int), align_of(int), new_count, loc);
|
||||
__dynamic_array_reserve(&nm.entries, entry_size, entry_align, m.entries.len, loc);
|
||||
for i in 0..new_count do nm.hashes[i] = -1;
|
||||
for i in 0..new_count-1 do nm.hashes[i] = -1;
|
||||
|
||||
for i in 0..m.entries.len {
|
||||
for i in 0..m.entries.len-1 {
|
||||
if len(nm.hashes) == 0 do __dynamic_map_grow(new_header, loc);
|
||||
|
||||
entry_header := __dynamic_map_get_entry(header, i);
|
||||
|
||||
@@ -17,7 +17,7 @@ __print_u64 :: proc(fd: os.Handle, u: u64) {
|
||||
}
|
||||
i -= 1; a[i] = digits[u % b];
|
||||
|
||||
os.write(fd, a[i..]);
|
||||
os.write(fd, a[i:]);
|
||||
}
|
||||
|
||||
__print_i64 :: proc(fd: os.Handle, u: i64) {
|
||||
@@ -38,7 +38,7 @@ __print_i64 :: proc(fd: os.Handle, u: i64) {
|
||||
i -= 1; a[i] = '-';
|
||||
}
|
||||
|
||||
os.write(fd, a[i..]);
|
||||
os.write(fd, a[i:]);
|
||||
}
|
||||
|
||||
__print_caller_location :: proc(fd: os.Handle, using loc: Source_Code_Location) {
|
||||
@@ -256,7 +256,7 @@ bounds_check_error :: proc "contextless" (file: string, line, column: int, index
|
||||
__print_caller_location(fd, Source_Code_Location{file, line, column, ""});
|
||||
os.write_string(fd, " Index ");
|
||||
__print_i64(fd, i64(index));
|
||||
os.write_string(fd, " is out of bounds range 0..");
|
||||
os.write_string(fd, " is out of bounds range 0:");
|
||||
__print_i64(fd, i64(count));
|
||||
os.write_byte(fd, '\n');
|
||||
debug_trap();
|
||||
@@ -270,9 +270,9 @@ slice_expr_error :: proc "contextless" (file: string, line, column: int, lo, hi:
|
||||
__print_caller_location(fd, Source_Code_Location{file, line, column, ""});
|
||||
os.write_string(fd, " Invalid slice indices: ");
|
||||
__print_i64(fd, i64(lo));
|
||||
os.write_string(fd, "..");
|
||||
os.write_string(fd, ":");
|
||||
__print_i64(fd, i64(hi));
|
||||
os.write_string(fd, "..");
|
||||
os.write_string(fd, ":");
|
||||
__print_i64(fd, i64(len));
|
||||
os.write_byte(fd, '\n');
|
||||
debug_trap();
|
||||
@@ -285,9 +285,9 @@ dynamic_array_expr_error :: proc "contextless" (file: string, line, column: int,
|
||||
__print_caller_location(fd, Source_Code_Location{file, line, column, ""});
|
||||
os.write_string(fd, " Invalid dynamic array values: ");
|
||||
__print_i64(fd, i64(low));
|
||||
os.write_string(fd, "..");
|
||||
os.write_string(fd, ":");
|
||||
__print_i64(fd, i64(high));
|
||||
os.write_string(fd, "..");
|
||||
os.write_string(fd, ":");
|
||||
__print_i64(fd, i64(max));
|
||||
os.write_byte(fd, '\n');
|
||||
debug_trap();
|
||||
|
||||
Reference in New Issue
Block a user