Skip to content

Inplace unescape #81

@xamgore

Description

@xamgore

It is generally true that each HTML entity has a greater length in bytes than its Unicode symbol.

Which makes it possible to modify the string or vec buffer directly without an extra allocation.

All but two entities are as long or longer than their expansion, so allocating the output buffer to be the same size as the input will usually prevent multiple allocations and generally won’t over-allocate by very much.

The two entities are ⋙̸ (⋙̸) and ⋘̸ (⋘̸) which are both five byte entities with six byte expansions.

As these two are extremely rear I would not bother with them as it is performance vs. purity trade-off.

  • these symbols could be mapped to ≪̸ which is semantically close
  • the function could signal about its incompleteness
  • the function could switch to the classical implementation for the rest of the string

Thanks for the great work you've done! 👍🏻

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions