bytecodealliance / bytecodealliance/wit-bindgen

c# explore using readonly/span of memory for exports

Open
#1,151 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.5k
Forks
286
Avg merge
6h 32m
Merged PRs (30d)
19

Description

In the exports, we generate

```cs
public interface ITest {
static abstract void EmptyListParam(byte[] a);
}
```

but we probably generate
```cs
public interface ITest {
static abstract void EmptyListParam(ReadOnlySpan a)
}
```
because we don't expect the callee to modify that memory space.

This would allow us to pass the host buffer, instead of making a managed copy on the heap (and GC it later).

Note they could always make copy themself.

```cs
public static void EmptyListParam(ReadOnlySpan a) {
byte[] copy = a.ToArray();
}
```

_Originally posted by @pavelsavara in https://github.com/bytecodealliance/wit-bindgen/issues/1138#issuecomment-2625033304_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.