{"version":"2.1.229","anchor":"byte-budget-string-truncation-no-longer-allocates-a-buffer","canonical_anchor":"byte-budget-string-truncation-no-longer-allocates-a-buffer","heading":"Byte-budget string truncation no longer allocates a Buffer","tier":"internal","area":"Elsewhere","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.229\/e\/byte-budget-string-truncation-no-longer-allocates-a-buffer","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.229","markdown":"### Byte-budget string truncation no longer allocates a Buffer\n\nTrimming text to a byte limit got cheaper, with the same results.\n\n**What**\n\nThe helper that trims a string to a byte budget now returns early when three bytes per character would still fit, and otherwise encodes and decodes with TextEncoder\/TextDecoder, stripping any trailing replacement character left by a cut mid-sequence. Same results, less allocation.\n\n**Evidence**\n\n`new TextDecoder().decode(r.subarray(0, t)).replace(\/\\uFFFD+$\/, \"\")`\n\n- Area: Elsewhere\n- Tier: Under the hood\n- Useful: 1\/5\n- Signal: 0\/5"}