Replies: 1 comment
-
I believe because we can't know beforehand how long its going to be after converting to UTF-8. So we allocate the maximum amount of memory its possibly going to take and then adjust it afterwards when we know how much it really took after the conversion. If you have a suggestion how to do it only with one allocation that would be great! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Within the implementation of passStringToWasm0
In the implementation of passStringToWasm0, the ptr is reallocated twice:
Instead of reallocating arg.length * 3 initially, The length is determined after checking the written property of the view and then reallocated, And finally, the buf is appended to the ptr.
It seems possible to achieve this with only one reallocation. I'm curious about the considerations behind choosing an implementation with two reallocations.
Beta Was this translation helpful? Give feedback.
All reactions