Skip to content

Conversation

@PennyWang-Tank
Copy link

When there is no change in width and height, there is no need to reallocate memory and reuse existing memory.

@koral-- koral-- requested a review from Copilot September 2, 2025 13:55
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

Fixes a bug in the JpgEncoder::reserveData method where it incorrectly returned 0 instead of true when no memory reallocation was needed.

  • Changed return value from 0 to true when width and height haven't changed
  • Ensures consistent boolean return type behavior for the reserveData method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

JpgEncoder::reserveData(uint32_t width, uint32_t height) {
if (width == mMaxWidth && height == mMaxHeight) {
return 0;
return true;
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

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

The function returns true when no reallocation is needed, but this should be verified against the function's contract. If reserveData is expected to return true for success and false for failure, then this change is correct. However, if the function should indicate whether new data was actually reserved, returning true when no allocation occurred might be misleading to callers.

Copilot uses AI. Check for mistakes.
@koral--
Copy link
Member

koral-- commented Sep 2, 2025

LGTM but please add a sign-off so DCO can pass.

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