Commit Graph

26 Commits

Author SHA1 Message Date
Tuan Tran
b5319483ed
chore(docs): fix comments that do not start with the name of the exported element. (#20906) 2024-07-10 06:00:36 +00:00
Qt
febb7b7ece
docs(math): update math docs (#19615) 2024-03-01 12:36:00 +00:00
Qt
35c4243da9
docs(math): update math docs (#19590) 2024-02-28 15:48:57 +00:00
Qt
aa9ff3d8a7
refactor: use errors.New to replace fmt.Errorf with no parameters (#19548) 2024-02-24 21:14:13 +00:00
Dev Ojha
ac48269f98
perf: Speedup sdk.Int overflow checks (#19386) 2024-02-09 08:51:11 +00:00
Dev Ojha
0c6b6d49cb
perf: Remove duplicate overflow check from int.Mul (#18874) 2023-12-26 12:04:10 +00:00
Julien Robert
519c55cd53
refactor(confix): properly update migrate and diff command (#18596) 2023-11-30 09:59:23 +00:00
ocnc
7d5e9f1c23
feat(math): add safe arithmetic (#18552) 2023-11-28 07:54:04 +00:00
Hieu Vu
e7e1c36222
feat(math): Add mutative api for NewIntFromBigInt (#18030) 2023-11-07 08:36:39 +00:00
Marko
54701b7a54
chore: fix comments (#18043) 2023-10-11 09:22:45 +00:00
Hieu Vu
150013ee50
feat(math): add mutative api for Int.BigInt() (#17803) 2023-09-25 12:12:23 +00:00
Roman
f304ebfc8f
fix(math): Revert "perf: optimize math.Int.Size for small values (#17497)" (#17736) 2023-09-14 16:55:58 +00:00
Elias Naur
952328a4ed
perf: optimize math.Int.Size for small values (#17497) 2023-08-22 21:54:34 +00:00
Julien Robert
bf249162e4
fix(math): revert #16263 and add test cases (#17489) 2023-08-21 14:07:40 +00:00
Julien Robert
1089f715fc
fix(math): fix panic in .Size() (#17480) 2023-08-21 09:20:30 +00:00
Aleksandr Bezobchuk
658a88a309
fix(math): defend NewIntFromBigInt argument mutation (#17352) 2023-08-10 20:10:38 +00:00
Julien Robert
5442197d6b
chore: cherry-pick some inj changes (#17109) 2023-07-24 13:07:06 +00:00
Jacob Gadikian
f0aec3f30d
style: use thelper (#16777) 2023-07-03 13:33:05 +00:00
Julien Robert
8c72f66396
refactor!: remove types/math aliases (#16798) 2023-06-30 17:09:03 +00:00
Emmanuel T Odeke
9b9e319d1a
perf: math: make Int.Size() faster by computation not len(MarshalledBytes) (#16263)
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
2023-06-08 15:15:52 +00:00
Facundo Medica
43cfdfe618
fix(math): FormatInt returns error on empty string (#15714) 2023-04-06 14:10:30 +00:00
Marko
1f2875d445
style: gofumpt linting (#15605) 2023-03-30 06:27:38 +00:00
Emmanuel T Odeke
3e85182baa
perf: math: optimize and test FormatInt + simplify LegacyNewDecFromStr (#14010)
Optimizes and tests FormatInt by removing inefficient string
concatenation but also making it so much clearer with how one would
express adding thousand separators in natural language. It uses
a combination of strings.Builder whose values can be grown

The performance improvement is stark in every dimension:

```shell
$ benchstat before.txt after3.txt
name                          old time/op    new time/op    delta
DecimalValueRendererFormat-8    4.48µs ± 1%    2.11µs ± 2%  -52.90%  (p=0.000 n=10+10)

name                          old alloc/op   new alloc/op   delta
DecimalValueRendererFormat-8    3.62kB ± 0%    0.78kB ± 0%  -78.59%  (p=0.000 n=10+10)

name                          old allocs/op  new allocs/op  delta
DecimalValueRendererFormat-8      83.0 ± 0%      28.0 ± 0%  -66.27%  (p=0.000 n=10+10)
```

While here, also simplified zero padding for LegacyNewDecFromStr
simply by using strings.Repeat instead of a convoluted
fmt.Sprintf+strconv.Itoa.

Fixes #14008
Fixes #14003

Co-authored-by: Marko <marbar3778@yahoo.com>
2022-11-29 21:00:47 +00:00
Amaury
10ac33edb8
refactor: Move FormatCoins to core (#13306)
* refactor: Move FormatCoins to `core`

* Rename to shorter names

* Add chaneglog

* Don't panic

* add comments

* go mod tidy

* fix changelog

* move structs to top

* Fix test

* go mod tidy

* Refactor tests
2022-10-19 11:21:24 +00:00
Emmanuel T Odeke
b2af716bf7
math: derive marshalled byte length from copy, not blind assumptions (#12010)
The specification of "copy", the builtin function per
https://pkg.go.dev/builtin#copy, says that it returns the minimum of
len(src) and len(dst) when invoked as:

   copy(dst, src)

of which the prior code blindly assumed that everytime that
copy is invoked that the buffer provided had enough size
to accomodate the contents of *.MarshalTo but this isn't true
at all if len(data) is less than the values of .Marshal()
2022-05-23 12:08:11 +02:00
Aleksandr Bezobchuk
4f04beae34
refactor!: create math go sub module (#11788) 2022-04-28 14:05:21 -04:00