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

CoinsRegistry: Optimize GetMyInputs #11618

Conversation

kiminuo
Copy link
Collaborator

@kiminuo kiminuo commented Oct 2, 2023

No description provided.

@kiminuo kiminuo force-pushed the feature/2023-10-02-CoinsRegistry-optimize-GetMyInputs branch from 97b18cb to 2482edc Compare October 2, 2023 06:21
@kiminuo kiminuo marked this pull request as ready for review October 2, 2023 07:09
@@ -278,16 +278,15 @@ public bool TryGetSpentCoinByOutPoint(OutPoint outPoint, [NotNullWhen(true)] out
}
}

public IEnumerable<SmartCoin> GetMyInputs(SmartTransaction transaction)
public IReadOnlyList<SmartCoin> GetMyInputs(SmartTransaction transaction)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IReadOnlyList implements IEnumerable and notably it allows us to work with the result efficiently.

{
var inputs = transaction.Transaction.Inputs.Select(x => x.PrevOut).ToArray();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removes needless allocations.

Copy link
Collaborator

@adamPetho adamPetho left a comment

Choose a reason for hiding this comment

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

Nice!

@adamPetho adamPetho merged commit 2a431ea into WalletWasabi:master Oct 2, 2023
6 of 7 checks passed
@kiminuo kiminuo deleted the feature/2023-10-02-CoinsRegistry-optimize-GetMyInputs branch October 4, 2023 07:11
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.

None yet

2 participants