Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writeByte() may be improved for byte array based BufferedData #284

Closed
artemananiev opened this issue Sep 6, 2024 · 0 comments · Fixed by #285
Closed

writeByte() may be improved for byte array based BufferedData #284

artemananiev opened this issue Sep 6, 2024 · 0 comments · Fixed by #285
Assignees
Labels
Performance Issues related to performance concerns.

Comments

@artemananiev
Copy link
Member

ByteArrayBufferedData.writeByte() method looks like this:

    public void writeByte(final byte b) {
        validateCanWrite(1);
        final int pos = buffer.position();
        array[arrayOffset + pos] = b;
        buffer.position(pos + 1);
    }

Besides putting the byte to the byte array, it has a check and two calls to buffer.position() When multiple bytes are written one by one, this overhead becomes noticeable. For example, this writeByte() method is used in Utf8Tools, which is used to write all strings.

@artemananiev artemananiev added the Performance Issues related to performance concerns. label Sep 6, 2024
@artemananiev artemananiev self-assigned this Sep 6, 2024
artemananiev added a commit that referenced this issue Sep 11, 2024
…ta (#285)

Fixes: #284
Reviewed-by: Anthony Petrov <anthony@swirldslabs.com>, Ivan Malygin <ivan@swirldslabs.com>
Signed-off-by: Artem Ananev <artem.ananev@swirldslabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Issues related to performance concerns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant