Esc

format_push_string

Finds append(*b, tprint(...)), which formats into a new string to add it to a builder.

Category perf, warn by default.

Example
#import "Basic";

describe :: (name: string, value: int) -> string {
    builder: String_Builder;
    defer free_buffers(*builder);

    append(*builder, tprint("%: %\n", name, value));

    return builder_to_string(*builder);
}

main :: () {
    print("%\n", describe("x", 1));
}
Diagnostic
warning[format_push_string]: `tprint` formats into a new string just to append it to a builder
  --> example.jai:7:5
   |
 7 |     append(*builder, tprint("%: %\n", name, value));
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: `print_to_builder` writes into the builder directly
   |
 7 ~     print_to_builder(*builder, "%: %\n", name, value);
   |
   = note: `format_push_string` is `warn` by default
Fixed
#import "Basic";

describe :: (name: string, value: int) -> string {
    builder: String_Builder;
    defer free_buffers(*builder);

    print_to_builder(*builder, "%: %\n", name, value);

    return builder_to_string(*builder);
}

main :: () {
    print("%\n", describe("x", 1));
}

Fires on a call of a procedure noted @AppendsString (the library's append of a string) whose string is a call of one noted @FormatsToString (tprint, sprint).