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

Make sdk.Coins.Add more efficient #2627

Closed
sunnya97 opened this issue Oct 30, 2018 · 4 comments
Closed

Make sdk.Coins.Add more efficient #2627

sunnya97 opened this issue Oct 30, 2018 · 4 comments
Labels

Comments

@sunnya97
Copy link
Member

As proposed by @ValarDragon in #2385

Currently our coins.Add method doesn't take advantage of the lists being sorted, so this takes O(N) time effectively...We should probably implement the logarithmic coins adding for this case then, or just make coin addition time less biasable in general.

@sunnya97 sunnya97 changed the title Make coins.Add more efficient Make sdk.Coins.Add more efficient Oct 30, 2018
@jackzampolin
Copy link
Member

I think this has been addressed. Closing. cc @alexanderbez

@ValarDragon
Copy link
Contributor

It is not. https://github.com/cosmos/cosmos-sdk/blob/master/types/coin.go#L223

@kochetkov-av
Copy link
Contributor

It looks like current implementation fully relies on coins being sorted lexicographically by coin.Denom and couldn't be optimized significantly.

@colin-axner colin-axner mentioned this issue Sep 16, 2020
4 tasks
@ValarDragon
Copy link
Contributor

Agreed, the only place where we could get benefits is from the case where one adds a set of coins with many entries, and one with few entries. However since its stored in a sorted array, insert must be O(N), so there doesn't seem to be a notable performance benefit to be had.

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

No branches or pull requests

6 participants