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

refactor: Rewrite convertImmutable #2445

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions client/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,11 @@ func (val FieldValue) Bytes() ([]byte, error) {
}

func convertImmutable[T any](vals []immutable.Option[T]) []any {
var out []any
for _, val := range vals {
if !val.HasValue() {
out = append(out, nil)
continue
out := make([]any, len(vals))
for i := range vals {
if vals[i].HasValue() {
out[i] = vals[i].Value()
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: this is a small change with potentially significant impact. I wonder why no tests cover this.
Would be great to add some tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is tested, I was mistaken in your PR - I just rewrote it because it was really ugly

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this change has any impact other than improving the efficiency of the code. The returned result is the same.

}
out = append(out, val.Value())
}
return out
}
Loading