1
0
mirror of https://github.com/golang/go synced 2024-11-19 00:14:39 -07:00
go/src/reflect
Daniel Martí 788e038e5d reflect: make all flag.mustBe* methods inlinable
mustBe was barely over budget, so manually inlining the first flag.kind
call is enough. Add a TODO to reverse that in the future, once the
compiler gets better.

mustBeExported and mustBeAssignable were over budget by a larger amount,
so add slow path functions instead. This is the same strategy used in
the sync package for common methods like Once.Do, for example.

Lots of exported reflect.Value methods call these assert-like unexported
methods, so avoiding the function call overhead in the common case does
shave off a percent from most exported APIs.

Finally, add the methods to TestIntendedInlining.

While at it, replace a couple of uses of the 0 Kind with its descriptive
name, Invalid.

name     old time/op    new time/op    delta
Call-8     68.0ns ± 1%    66.8ns ± 1%  -1.81%  (p=0.000 n=10+9)
PtrTo-8    8.00ns ± 2%    7.83ns ± 0%  -2.19%  (p=0.000 n=10+9)

Updates #7818.

Change-Id: Ic1603b640519393f6b50dd91ec3767753eb9e761
Reviewed-on: https://go-review.googlesource.com/c/go/+/166462
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-09 19:50:24 +00:00
..
all_test.go reflect: fix panic when Value.IsNil is called for UnsafePointer 2018-12-24 01:23:25 +00:00
asm_386.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_amd64.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_amd64p32.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_arm64.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_arm.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_mips64x.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_mipsx.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_ppc64x.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_s390x.s reflect: fix s390x reflect method calls 2018-09-30 20:30:55 +00:00
asm_wasm.s all: rename WebAssembly instructions according to spec changes 2019-03-03 21:10:01 +00:00
deepequal.go reflect: reuse values during comparison of maps in DeepEqual 2018-05-31 15:18:53 +00:00
example_test.go reflect: add an example for Kind 2018-10-03 22:38:53 +00:00
export_test.go reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
makefunc.go reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
set_test.go reflect: define MyBuffer more locally in TestImplicitMapConversion 2018-04-18 12:47:39 +00:00
swapper.go reflect: audit and explain safety of all unsafe.Pointer additions 2017-12-01 21:05:40 +00:00
tostring_test.go
type.go all: simplify multiple for loops 2019-03-08 14:29:19 +00:00
value.go reflect: make all flag.mustBe* methods inlinable 2019-03-09 19:50:24 +00:00