mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
b4d93379c440f7311448028e31fa4efba8b8ede1
When storing a string in an interface value that escapes, Go has to heap allocate space for the string header, as interface values can only store pointers. In text-heavy applications, this can lead to hundreds of allocations per frame due to semantic.LabelOp, the primary user of string-typed references in ops. Instead of allocating each string header individually, provide a slice of strings to store string-typed references in, and store pointers into this slice as the actual references. This only allocates when resizing the slice's backing array, and averages out to no allocations, as the backing array gets reused between calls to Ops.Reset. We introduce two new functions, Write1String and Write2String, which make use of this new slice for their last argument. We could've automated this in the existing Write1 and Write2 methods, but that would require type assertions on each call, and the vast majority of ops do not make use of strings. Signed-off-by: Dominik Honnef <dominik@honnef.co>
Gio - https://gioui.org
Immediate mode GUI programs in Go for Android, iOS, macOS, Linux, FreeBSD, OpenBSD, Windows, and WebAssembly (experimental).
Installation, examples, documentation
Go to gioui.org.
Issues
File bugs and TODOs through the issue tracker or send an email to ~eliasnaur/gio@todo.sr.ht. For general discussion, use the mailing list: ~eliasnaur/gio@lists.sr.ht.
Contributing
Post discussion to the mailing list and patches to gio-patches. No Sourcehut account is required and you can post without being subscribed.
See the contribution guide for more details.
An official GitHub mirror is available.
Tags
Pre-1.0 tags are provided for reference only, and do not designate releases with ongoing support. Bugfixes will not be backported to older tags.
Tags follow semantic versioning. In particular, as the major version is zero:
- breaking API or behavior changes will increment the minor version component.
- non-breaking changes will increment the patch version component.
Description
Languages
Go
89.6%
C
7%
Java
1.7%
Objective-C
1.6%