Skip to content

Conversation

@mykaul
Copy link

@mykaul mykaul commented Aug 11, 2025

Very similar changes to the Python driver (scylladb/python-driver#520 ), there are redundant calls to len(). Removed them.

Follow-up patch will hopefully change the Encode() functions to accept the length of the buffer, to remove another len() call (just as done in the Python change mentioned above).

Very similar changes to the Python driver (scylladb/python-driver#520 ),
there are redundant calls to len(). Removed them.

Follow-up patch will hopefully change the Encode() functions to accept the length of the buffer,
to remove another len() call (just as done in the Python change mentioned above).

Signed-off-by: Yaniv Kaul <[email protected]>
@mykaul mykaul requested a review from Copilot August 11, 2025 17:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes redundant calls to len() in compression-related code by caching the length values in local variables. This optimization reduces function call overhead by storing the length once and reusing it instead of repeatedly calling len() on the same data.

Key changes:

  • Cache len(data) in LZ4 compression encoding
  • Cache len(f.buf) in frame finishing logic to avoid multiple length calculations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lz4/lz4.go Caches len(data) to avoid redundant calls in LZ4 compression encoding
frame.go Caches len(f.buf) to eliminate multiple length calculations in frame finishing

@dkropachev dkropachev merged commit ff17f80 into scylladb:master Aug 11, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants