cosmos / iavl

Merkleized IAVL+ Tree implementation in Go
Apache License 2.0
420 stars 263 forks source link

refactor: remove unnecessary/repeated/pedantic code in BatchWithFlusher #846

Closed odeke-em closed 11 months ago

odeke-em commented 11 months ago

This change removes unnecessary code that could be made clearer in its much simpler, more idiomatic Go form.

Summary by CodeRabbit

coderabbitai[bot] commented 11 months ago

[!WARNING]

Rate Limit Exceeded

@odeke-em has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 15 minutes and 24 seconds before requesting another review.

How to resolve this issue? After the wait time has elapsed, convert this PR to a draft and then mark it as ready for review again to re-trigger the review. Alternatively, you can push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.
How do rate limits work? CodeRabbit enforces hourly rate limits for each developer per repository. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://coderabbit.ai/docs/faq) for further information.
Commits Files that changed from the base of the PR and between fa35c63d2662520dd4afc484e93a9b59eaab97bc and 8cdba581074b361b17f775bf7aa806b1fed9c7c6.

Walkthrough

The changes primarily focus on the BatchWithFlusher struct in batch.go, enhancing readability and maintainability. The modifications include a type assertion update, parameter type changes for Set and Delete methods, and streamlined error handling.

Changes

File Summary
batch.go The BatchWithFlusher struct and its methods have been updated. The type assertion line is replaced with a more idiomatic form. The Set and Delete methods now accept two []byte parameters instead of one. Error handling in these methods is simplified with inline error checks.

🐇 "In the land of code, where the shadows lie, A rabbit hopped, with a twinkle in its eye. With each line changed, each bug set free, The code grew stronger, as strong as it could be. So let's celebrate this day, with a carrot cake slice, For in the realm of coding, every improvement is nice!" 🥕🍰


Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - If you reply to a *review comment* from CodeRabbit, the bot will automatically respond. - To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment - Note: Review comments are made on code diffs or files, not on the PR overview. - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai help` to get help. Note: For conversation with the bot, please use the review comments on code diffs or files. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - The JSON schema for the configuration file is available [here](https://coderabbit.ai/integrations/coderabbit-overrides.json). - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.json`
odeke-em commented 11 months ago

Kindly /cc-ing @julienrbrt @tac0turtle @elias-orijtech

tac0turtle commented 11 months ago

@mergifyio backport release/v1.x.x

mergify[bot] commented 11 months ago

backport release/v1.x.x

✅ Backports have been created

* [#847 refactor: remove unnecessary/repeated/pedantic code in BatchWithFlusher (backport #846)](https://github.com/cosmos/iavl/pull/847) has been created for branch `release/v1.x.x`