Skip to content

fromWtf8Array with no start/length parameters ? #9

Open

Description

@wingo

My understanding is that the interface to fromWtf8Array was taken from stringref, where the use case might be, you have a buffered I/O port with an (array i8) holding your bytes, and you want to decode a part of that buffer. In that case it definitely makes sense to take a start and an offset.

However for wtf-8 string conversion on the boundary, for languages that use UTF-8 or WTF-8 internally -- i.e., where you're not using externref to actually represent the strings, but instead you are using the JS string builtins to perform a more efficient encode/decode when communicating with the host -- there, you are much more likely to just have a full (array i8). You will be decoding the whole thing. In that case binary size and runtime overhead will be minimized if we can remove the start and end arguments, and just assume we transcode the whole buffer.

Activity

  1. eqrion commented on Dec 5, 2023

    @eqrion
    Collaborator

    @wingo Would this new function just be a short hand for:

    (call $fromWtf8Array
      (i32.const 0)
      (array.length
        (local.get $arr)
      )
      (local.get $arr)
    )
    

    I can see that being a good binary size reduction (but would also be interested in some data).

    runtime overhead

    Are you imagining this operation would be more efficient than the version operating on a slice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions