mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-26 17:11:40 +00:00
surface: parse text bindings with stack fallback (#13918)
Text binding actions previously allocated a temporary buffer for every escaped string. Use a 256-byte stack fallback allocator so typical bindings avoid the transient heap allocation while larger values continue to use the existing heap-backed behavior.
This commit is contained in:
@@ -4872,10 +4872,10 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||||||
},
|
},
|
||||||
|
|
||||||
.text => |data| {
|
.text => |data| {
|
||||||
// For text we always allocate just because its easier to
|
var stack = std.heap.stackFallback(256, self.alloc);
|
||||||
// handle all cases that way.
|
const alloc = stack.get();
|
||||||
const buf = try self.alloc.alloc(u8, data.len);
|
const buf = try alloc.alloc(u8, data.len);
|
||||||
defer self.alloc.free(buf);
|
defer alloc.free(buf);
|
||||||
const text = configpkg.string.parse(buf, data) catch |err| {
|
const text = configpkg.string.parse(buf, data) catch |err| {
|
||||||
log.warn(
|
log.warn(
|
||||||
"error parsing text binding text={s} err={}",
|
"error parsing text binding text={s} err={}",
|
||||||
|
|||||||
Reference in New Issue
Block a user