-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add String setters to many structs #142
Comments
This will be much easier when we have fixed-sized arrays in FFI structs. I can add something by hand if it's needed, but when arrays land, I can replace many lines of boilerplate with something much cleaner here. |
Fixed in the latest Dart builds: dart-lang/sdk#35763 I can start working on this now in the partitioned dart2.13 branch: https://github.com/timsneath/win32/tree/dart2.13 |
Fixed in a1a1d43 |
How could we turn extension CharArray on Array<Int8> {
String getDartString(int maxLength) {
var list = <int>[];
for (var i = 0; i < maxLength; i++) {
if (this[i] != 0) list.add(this[i]);
}
return utf8.decode(list);
}
void setDartString(String s, int maxLength) {
var list = utf8.encode(s);
for (var i = 0; i < maxLength; i++) {
this[i] = i < list.length ? list[i] : 0;
}
}
} |
My guess is that, while inefficient, the performance cost of the copy is tiny compared to the Win32 calls themselves. If it's only a few thousand instructions, it's probably not worth worrying about. But curious if you've measured this? |
Related: dart-lang/sdk#45508 |
No description provided.
The text was updated successfully, but these errors were encountered: