Skip to content

refactor: use the built-in max/min to simplify the code#2687

Open
nuxtreact wants to merge 1 commit intossvlabs:stagefrom
nuxtreact:stage
Open

refactor: use the built-in max/min to simplify the code#2687
nuxtreact wants to merge 1 commit intossvlabs:stagefrom
nuxtreact:stage

Conversation

@nuxtreact
Copy link

In Go 1.21, the standard library includes built-in max/min function, which can greatly simplify the code.

Signed-off-by: nuxtreact <nuxtreact@outlook.com>
@nuxtreact nuxtreact requested review from a team as code owners February 12, 2026 16:27
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 12, 2026

Greptile Overview

Greptile Summary

Replaced manual min calculation pattern (if end > len(indices) { end = len(indices) }) with Go's built-in min() function in two batching loops within ensureProposerEpoch and ensureSyncPeriod methods.

  • Simplified code by using min(i+batch, len(indices)) instead of the three-line conditional pattern
  • Leverages Go 1.21+ built-in function for cleaner, more idiomatic code
  • No functional changes, purely a refactoring for readability

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • Simple refactoring that replaces a well-tested pattern with equivalent built-in functionality. The logic is mathematically identical, and Go 1.24.6 is in use (well above the required Go 1.21). No behavioral changes or edge cases introduced.
  • No files require special attention

Important Files Changed

Filename Overview
operator/duties/beacon_adapter.go Replaced manual min calculation with built-in min() function in two batching loops

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@iurii-ssv iurii-ssv left a comment

Choose a reason for hiding this comment

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

Thanks!

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.

3 participants