aboutsummaryrefslogtreecommitdiff
path: root/core/encoding/json
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-09-23 17:17:14 +0100
committergingerBill <bill@gingerbill.org>2020-09-23 17:17:14 +0100
commitfc4fdd588e5bd0c45d04c792267a0f4434c6a38e (patch)
tree59bcddc60248dd78ed1155dd7a6ae7ae3de2e07e /core/encoding/json
parent4844dd4d96f0921f44e70c9960d3e4476aad7115 (diff)
Remove usage of `do` in core library
Diffstat (limited to 'core/encoding/json')
-rw-r--r--core/encoding/json/marshal.odin24
-rw-r--r--core/encoding/json/tokenizer.odin20
-rw-r--r--core/encoding/json/types.odin4
3 files changed, 32 insertions, 16 deletions
diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin
index df5a0754e..92b18c9e3 100644
--- a/core/encoding/json/marshal.odin
+++ b/core/encoding/json/marshal.odin
@@ -161,7 +161,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
case Type_Info_Array:
write_byte(b, '[');
for i in 0..<info.count {
- if i > 0 do write_string(b, ", ");
+ if i > 0 { write_string(b, ", "); }
data := uintptr(v.data) + uintptr(i*info.elem_size);
marshal_arg(b, any{rawptr(data), info.elem.id});
@@ -172,7 +172,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
write_byte(b, '[');
array := cast(^mem.Raw_Dynamic_Array)v.data;
for i in 0..<array.len {
- if i > 0 do write_string(b, ", ");
+ if i > 0 { write_string(b, ", "); }
data := uintptr(array.data) + uintptr(i*info.elem_size);
marshal_arg(b, any{rawptr(data), info.elem.id});
@@ -183,7 +183,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
write_byte(b, '[');
slice := cast(^mem.Raw_Slice)v.data;
for i in 0..<slice.len {
- if i > 0 do write_string(b, ", ");
+ if i > 0 { write_string(b, ", "); }
data := uintptr(slice.data) + uintptr(i*info.elem_size);
marshal_arg(b, any{rawptr(data), info.elem.id});
@@ -205,7 +205,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
entry_size := ed.elem_size;
for i in 0..<entries.len {
- if i > 0 do write_string(b, ", ");
+ if i > 0 { write_string(b, ", "); }
data := uintptr(entries.data) + uintptr(i*entry_size);
header := cast(^Map_Entry_Header)data;
@@ -223,7 +223,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
case Type_Info_Struct:
write_byte(b, '{');
for name, i in info.names {
- if i > 0 do write_string(b, ", ");
+ if i > 0 { write_string(b, ", "); }
write_quoted_string(b, name);
write_string(b, ": ");
@@ -271,7 +271,7 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
write_byte(b, '{');
for name, i in info.names {
- if i > 0 do write_string(b, ", ");
+ if i > 0 { write_string(b, ", "); }
bits := u64(info.bits[i]);
offset := u64(info.offsets[i]);
@@ -317,15 +317,21 @@ marshal_arg :: proc(b: ^strings.Builder, v: any) -> Marshal_Error {
bit_data = u64(x);
case 16:
x := (^u16)(v.data)^;
- if do_byte_swap do x = bits.byte_swap(x);
+ if do_byte_swap {
+ x = bits.byte_swap(x);
+ }
bit_data = u64(x);
case 32:
x := (^u32)(v.data)^;
- if do_byte_swap do x = bits.byte_swap(x);
+ if do_byte_swap {
+ x = bits.byte_swap(x);
+ }
bit_data = u64(x);
case 64:
x := (^u64)(v.data)^;
- if do_byte_swap do x = bits.byte_swap(x);
+ if do_byte_swap {
+ x = bits.byte_swap(x);
+ }
bit_data = u64(x);
case: panic("unknown bit_size size");
}
diff --git a/core/encoding/json/tokenizer.odin b/core/encoding/json/tokenizer.odin
index f5fab47f2..b3860d428 100644
--- a/core/encoding/json/tokenizer.odin
+++ b/core/encoding/json/tokenizer.odin
@@ -183,9 +183,11 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) {
case "false": token.kind = .False;
case "true": token.kind = .True;
case:
- if t.spec == .JSON5 do switch str {
- case "Infinity": token.kind = .Infinity;
- case "NaN": token.kind = .NaN;
+ if t.spec == .JSON5 {
+ switch str {
+ case "Infinity": token.kind = .Infinity;
+ case "NaN": token.kind = .NaN;
+ }
}
}
@@ -361,7 +363,9 @@ is_valid_number :: proc(str: string, spec: Specification) -> bool {
s = s[1:];
case '1'..'9':
s = s[1:];
- for len(s) > 0 && '0' <= s[0] && s[0] <= '9' do s = s[1:];
+ for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
+ s = s[1:];
+ }
case '.':
if spec == .JSON5 { // Allow leading decimal point
s = s[1:];
@@ -380,7 +384,9 @@ is_valid_number :: proc(str: string, spec: Specification) -> bool {
if len(s) >= 2 && s[0] == '.' && '0' <= s[1] && s[1] <= '9' {
s = s[2:];
- for len(s) > 0 && '0' <= s[0] && s[0] <= '9' do s = s[1:];
+ for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
+ s = s[1:];
+ }
}
if len(s) >= 2 && (s[0] == 'e' || s[0] == 'E') {
@@ -392,7 +398,9 @@ is_valid_number :: proc(str: string, spec: Specification) -> bool {
return false;
}
}
- for len(s) > 0 && '0' <= s[0] && s[0] <= '9' do s = s[1:];
+ for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
+ s = s[1:];
+ }
}
// The string should be empty now to be valid
diff --git a/core/encoding/json/types.odin b/core/encoding/json/types.odin
index cf94554ec..9b3124369 100644
--- a/core/encoding/json/types.odin
+++ b/core/encoding/json/types.odin
@@ -65,7 +65,9 @@ destroy_value :: proc(value: Value) {
}
delete(v);
case Array:
- for elem in v do destroy_value(elem);
+ for elem in v {
+ destroy_value(elem);
+ }
delete(v);
case String:
delete(v);