]> Cypherpunks repositories - gostls13.git/commit
encoding/gob: replace runtime values with constants in init()
authorTomasz Jezierski <tjomek.jezierski@gmail.com>
Mon, 1 Aug 2022 19:18:36 +0000 (21:18 +0200)
committerRob Pike <r@golang.org>
Mon, 8 Aug 2022 06:16:59 +0000 (06:16 +0000)
commit0f6ee42fe063a48d7825bc03097bbb714aafdb7d
treed11165f96ebb63d30d49583143ee31a234bb4452
parent0c4db1e347dc51589e5289388305b02108ca0aa1
encoding/gob: replace runtime values with constants in init()

Current init() implementation in `encoding/gob/decode.go` checks int/uint/uintptr bit size with reflection in runtime. We could replace it with values available on compile stage. This should reduce time and allocations on binary start.
Results from GODEBUG=inittrace=1:
before:
init encoding/gob @4.4 ms, 0.21 ms clock, 43496 bytes, 652 allocs
after:
init encoding/gob @4.4 ms, 0.15 ms clock, 41672 bytes, 643 allocs

Updates #54184

Change-Id: I46dda2682fb92519da199415e29401d61edce697
Reviewed-on: https://go-review.googlesource.com/c/go/+/420455
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/encoding/gob/decode.go