Add runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD where appropriate

This commit is contained in:
gingerBill
2023-02-10 16:23:33 +00:00
parent b427a4c8c9
commit 986cba584e
31 changed files with 201 additions and 60 deletions
+3
View File
@@ -5,6 +5,7 @@ import "core:io"
import "core:mem"
import "core:slice"
import "core:unicode"
import "core:runtime"
import "core:unicode/utf8"
// returns a clone of the string `s` allocated using the `allocator`
@@ -1425,7 +1426,9 @@ split_multi :: proc(s: string, substrs: []string, allocator := context.allocator
// TODO maybe remove duplicate substrs
// sort substrings by string size, largest to smallest
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
temp_substrs := slice.clone(substrs, context.temp_allocator)
defer delete(temp_substrs)
slice.sort_by(temp_substrs, proc(a, b: string) -> bool {
return len(a) > len(b)
})