Skip to content

Improve Codec.toBytes() performance #281

@OlegMazurov

Description

@OlegMazurov

Problem

Codec.toBytes() creates an instance of ByteArrayOutputStream() which in turn creates default byte[32] in its constructor.
Every time the current capacity is exhausted the underlying array is doubled in size and copied over, which has visible performance impact. That could be avoided by properly sizing the instance at creation.

Solution

Either a better default size could be used universally (256? 512?) or the actual size of item could be computed and passed to ByteArrayOutputStream(int). Performance effect of either solution should be evaluated.

Alternatives

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    PerformanceIssues related to performance concerns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions