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

Speedup Unmarshalling #4

Closed
nikolaydubina opened this issue Jun 11, 2022 · 4 comments
Closed

Speedup Unmarshalling #4

nikolaydubina opened this issue Jun 11, 2022 · 4 comments

Comments

@nikolaydubina
Copy link

Hi, thanks for awesome lib! I like how you structured currencies, methods, iota. very good.

I used it in my fpmoney package: https://github.com/nikolaydubina/fpmoney

I noticed that casting string or []byte to this enum is prohibitively expensive. It is more expensive that just string.

  • current code is like 1500ns
  • string / int / float 400ns+
  • switch case cast -> 300ns

I suggest you switching to switch case + adding benchmarks in this repo.

Please refer to repo for details.

Thanks!

once again, nice work!

@ferdypruis
Copy link
Owner

ferdypruis commented Jun 11, 2022

Hi Nikolay, and thank you.

I shall add the same sort of lookup maps as I have in my iso3166-pkg to improve resolving string values to constants.

@ferdypruis
Copy link
Owner

This change has a side-effect of fixing a bug where a historic currency would be returned for a reused numeric code.
For example 008 would result in ALK instead of ALL.

@ferdypruis
Copy link
Owner

Please give v1.2.1 a try

@nikolaydubina
Copy link
Author

nikolaydubina commented Jun 17, 2022

Works like a charm. Thanks!

https://github.com/nikolaydubina/fpmoney

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

No branches or pull requests

2 participants