mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-21 15:11:12 +00:00
Only call get_args() if args is actually used by using an indirect value
This commit is contained in:
@@ -15,6 +15,9 @@ Arguments to the current process.
|
||||
*/
|
||||
args := get_args()
|
||||
|
||||
@(private="file")
|
||||
internal_args_to_free: []string
|
||||
|
||||
@(private="file")
|
||||
get_args :: proc "contextless" () -> []string {
|
||||
context = runtime.default_context()
|
||||
@@ -22,13 +25,16 @@ get_args :: proc "contextless" () -> []string {
|
||||
for rt_arg, i in runtime.args__ {
|
||||
result[i] = string(rt_arg)
|
||||
}
|
||||
internal_args_to_free = result
|
||||
return result
|
||||
}
|
||||
|
||||
@(fini, private="file")
|
||||
delete_args :: proc "contextless" () {
|
||||
context = runtime.default_context()
|
||||
delete(args, heap_allocator())
|
||||
if internal_args_to_free != nil {
|
||||
context = runtime.default_context()
|
||||
delete(internal_args_to_free, heap_allocator())
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user