perf: Fixed leaks.

This commit is contained in:
Spencer Brower
2026-07-21 15:48:00 -04:00
parent 23288d34cd
commit 2fd18d0108
4 changed files with 5 additions and 8 deletions
-2
View File
@@ -365,7 +365,6 @@ test_gutter_pipes_align_with_source_pipe :: proc(t: ^testing.T) {
// For width=1: source line is "N | ...", so "|" at col 2. // For width=1: source line is "N | ...", so "|" at col 2.
// Empty gutter is " |" (width+1 spaces + "|"), so "|" at col 2. // Empty gutter is " |" (width+1 spaces + "|"), so "|" at col 2.
lines := strings.split(out, "\n", context.temp_allocator) lines := strings.split(out, "\n", context.temp_allocator)
defer delete(lines)
pipe_col := -1 pipe_col := -1
for line in lines { for line in lines {
idx := strings.index(line, "|") idx := strings.index(line, "|")
@@ -387,7 +386,6 @@ test_arrow_points_at_pipe :: proc(t: ^testing.T) {
// For width=1: arrow line is " --> ..." so ">" at col 3. // For width=1: arrow line is " --> ..." so ">" at col 3.
// Pipe lines are " |" so "|" at col 2. // Pipe lines are " |" so "|" at col 2.
lines := strings.split(out, "\n", context.temp_allocator) lines := strings.split(out, "\n", context.temp_allocator)
defer delete(lines)
pipe_col := -1 pipe_col := -1
for line in lines { for line in lines {
-2
View File
@@ -846,7 +846,6 @@ warn_missing_partial :: proc(
) { ) {
hint := "" hint := ""
available := collect_partial_names(partials) available := collect_partial_names(partials)
defer delete(available)
suggestion := suggest_correction(available, name) suggestion := suggest_correction(available, name)
if suggestion != "" { if suggestion != "" {
hint = fmt.tprintf("did you mean '%s'?", suggestion) hint = fmt.tprintf("did you mean '%s'?", suggestion)
@@ -872,7 +871,6 @@ warn_unmatched_block_overrides :: proc(
return return
} }
available := collect_block_names(parent) available := collect_block_names(parent)
defer delete(available)
parent_path := parent.path parent_path := parent.path
if parent_path == "" { if parent_path == "" {
parent_path = "<input>" parent_path = "<input>"
+4 -4
View File
@@ -6,7 +6,7 @@ import "core:strings"
// collect_struct_keys enumerates the visible field names of a struct value, // collect_struct_keys enumerates the visible field names of a struct value,
// including fields promoted via `using`-embedded structs. // including fields promoted via `using`-embedded structs.
collect_struct_keys :: proc(val: any, allocator := context.temp_allocator) -> []string { collect_struct_keys :: proc(val: any, allocator := context.temp_allocator) -> []string {
out: [dynamic]string out := make([dynamic]string, 0, 0, allocator)
collect_struct_keys_into(val, &out, allocator) collect_struct_keys_into(val, &out, allocator)
return out[:] return out[:]
} }
@@ -111,7 +111,7 @@ validate_key_path :: proc(
} }
if !found { if !found {
keys: [dynamic]string keys := make([dynamic]string, 0, 4, allocator)
for i := len(ctx) - 1; i >= 0; i -= 1 { for i := len(ctx) - 1; i >= 0; i -= 1 {
collect_struct_keys_into(ctx[i], &keys, allocator) collect_struct_keys_into(ctx[i], &keys, allocator)
} }
@@ -178,7 +178,7 @@ collect_partial_names :: proc(
partials: map[string]Template, partials: map[string]Template,
allocator := context.temp_allocator, allocator := context.temp_allocator,
) -> []string { ) -> []string {
out: [dynamic]string out := make([dynamic]string, 0, 0, allocator)
for name in partials { for name in partials {
append(&out, name) append(&out, name)
} }
@@ -191,7 +191,7 @@ collect_block_names :: proc(
tmpl: Template, tmpl: Template,
allocator := context.temp_allocator, allocator := context.temp_allocator,
) -> []string { ) -> []string {
out: [dynamic]string out := make([dynamic]string, 0, 0, allocator)
seen := make(map[string]bool, allocator) seen := make(map[string]bool, allocator)
defer delete(seen) defer delete(seen)
for &node in tmpl.nodes { for &node in tmpl.nodes {
+1
View File
@@ -139,6 +139,7 @@ test_validate_map_path_silent :: proc(t: ^testing.T) {
data := Params_Data { data := Params_Data {
params = {"social" = "x"}, params = {"social" = "x"},
} }
defer delete(data.params)
ctx := make([dynamic]any, 0, 1, context.temp_allocator) ctx := make([dynamic]any, 0, 1, context.temp_allocator)
append(&ctx, data) append(&ctx, data)