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

remove append from crypto library #653

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

remove append from crypto library #653

wants to merge 6 commits into from

Conversation

KElkhiyaoui
Copy link
Contributor

No description provided.

@KElkhiyaoui KElkhiyaoui requested a review from adecaro June 11, 2024 12:05
@KElkhiyaoui KElkhiyaoui self-assigned this Jun 11, 2024
Copy link
Contributor

@adecaro adecaro left a comment

Choose a reason for hiding this comment

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

LGTM, please address the json-related comment 👍

@@ -334,6 +334,7 @@ func GetAuditInfoForIssues(issues [][]byte, metadata []driver.IssueMetadata) ([]
if len(ia.OutputTokens) != len(md.ReceiversAuditInfos) || len(ia.OutputTokens) != len(md.OutputsMetadata) {
return nil, errors.Errorf("number of output does not match number of provided metadata")
}
outputs[k] = make([]*AuditableToken, len(md.ReceiversAuditInfos))
Copy link
Contributor

Choose a reason for hiding this comment

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

if you allocate the array as

outputs[k] = make([]*AuditableToken, 0, len(md.ReceiversAuditInfos))

Then you can keep append. The above call creates an array of size len(md.ReceiversAuditInfos) and 0 length.

}
return raw, nil
return json.Marshal(raw)
Copy link
Contributor

Choose a reason for hiding this comment

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

better to avoid json here given that it is slow.
What you could do is to obtain the 3 slices you need and then aggregate them by allocating a new slice of size the sum of the 3 slices. Then you can use append.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @adecaro, I will use bytes.Join(raw, separator) instead. It seems to be fit for purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants