mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-01 19:02:13 +00:00
Use intrinsics.alloca rather than context.temp_allocator in json.unmarshal_object
This commit is contained in:
@@ -6,6 +6,7 @@ import "core:reflect"
|
||||
import "core:strconv"
|
||||
import "core:strings"
|
||||
import "base:runtime"
|
||||
import "base:intrinsics"
|
||||
|
||||
Unmarshal_Data_Error :: enum {
|
||||
Invalid_Data,
|
||||
@@ -368,11 +369,14 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
|
||||
unmarshal_expect_token(p, .Colon)
|
||||
|
||||
fields := reflect.struct_fields_zipped(ti.id)
|
||||
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator)
|
||||
|
||||
field_used := make([]bool, len(fields), context.temp_allocator)
|
||||
field_test :: #force_inline proc "contextless" (field_used: [^]byte, index: int) -> bool {
|
||||
prev_set := field_used[index/8] & byte(index&7) != 0
|
||||
field_used[index/8] |= byte(index&7)
|
||||
return prev_set
|
||||
}
|
||||
|
||||
field_used := intrinsics.alloca((len(fields)+7)/8, 1)
|
||||
use_field_idx := -1
|
||||
|
||||
for field, field_idx in fields {
|
||||
@@ -393,10 +397,9 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
|
||||
}
|
||||
|
||||
if use_field_idx >= 0 {
|
||||
if field_used[use_field_idx] {
|
||||
if field_test(field_used, use_field_idx) {
|
||||
return .Multiple_Use_Field
|
||||
}
|
||||
field_used[use_field_idx] = true
|
||||
offset := fields[use_field_idx].offset
|
||||
type := fields[use_field_idx].type
|
||||
name := fields[use_field_idx].name
|
||||
|
||||
Reference in New Issue
Block a user