mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-14 23:21:25 -07:00
fix: use runtime.map_insert to not overallocate
This commit is contained in:
@@ -3,6 +3,7 @@ package json
|
||||
import "core:mem"
|
||||
import "core:unicode/utf8"
|
||||
import "core:unicode/utf16"
|
||||
import "core:runtime"
|
||||
import "core:strconv"
|
||||
|
||||
Parser :: struct {
|
||||
@@ -263,13 +264,10 @@ parse_object_body :: proc(p: ^Parser, end_token: Token_Kind) -> (obj: Object, er
|
||||
return
|
||||
}
|
||||
|
||||
if len(obj) == cap(obj) {
|
||||
reserve_error := reserve(&obj, max(1, cap(obj) * 2))
|
||||
if reserve_error != nil {
|
||||
return nil, .Out_Of_Memory
|
||||
}
|
||||
insert_success := runtime.map_insert(&obj, key, elem)
|
||||
if insert_success == nil {
|
||||
return nil, .Out_Of_Memory
|
||||
}
|
||||
obj[key] = elem
|
||||
|
||||
if parse_comma(p) {
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user