Skip to content

toHexString util: try String.fromCharCode api #277

@twoeths

Description

@twoeths

Is your feature request related to a problem? Please describe.

Refer to achingbrain/uint8arrays#30 (comment)

Given how efficient protobuf creates a string from Uint8Array in one go, we could try to use String.fromCharCode() api for our toHexString() function without using string concatenation (which create temporary strings that cause gc run more frequently)

Describe the solution you'd like

  • Create a function to map a number from 0 to 15 to char code
  • For each byte extract to 1st 4-bits uint and 2nd 4-bits uint
  • Combine to an array of char codes
  • Create string from there in one go

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions