3.3. Temporary string utilities

The TEMP_STRINGS module provides temporary string construction that avoids heap allocations. Temporary strings are allocated on the stack or in scratch memory and are valid only within the current scope, offering fast string building for formatting and output.

All functions and symbols are in “temp_strings” module, use require to get access to it.

require daslib/temp_strings

3.3.1. Function annotations

temp_strings.TempStringMacro

Function annotation that enables temporary string optimization.

3.3.2. Temporary string builders

temp_strings.build_temp_string(bldr: block<(var writer:StringBuilderWriter):void>; cb: block<(res:string#):void>)

Same as build_string, but delete the string after the callback is called. Intern strings are not deleted.

Arguments:

3.3.3. Temporary string conversion

3.3.3.1. temp_string

temp_strings.temp_string(arr: array<uint8>; cb: block<(res:string#):void>)

Construct string from array of bytes and pass it to the callback. Delete the string after the callback is called. Intern strings are not deleted.

Arguments:
  • arr : array<uint8>

  • cb : block<(res:string#):void>

temp_strings.temp_string(str: string; cb: block<(res:string#):void>)