]> Cypherpunks repositories - gostls13.git/commit
cmd/gc: optimize existence-only map lookups
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 22 Dec 2014 19:33:47 +0000 (11:33 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 7 Jan 2015 22:36:06 +0000 (22:36 +0000)
commit43e6923131c4c83e02f5263a9632d81819f15a62
tree0300e13f1f583aaac87fef92c999c9e50d1908f5
parent43c87aa481f4e10777b05bf05edd15403853348f
cmd/gc: optimize existence-only map lookups

The compiler converts 'val, ok = m[key]' to

        tmp, ok = <runtime call>
        val = *tmp

For lookups of the form '_, ok = m[key]',
the second statement is unnecessary.
By not generating it we save a nil check.

Change-Id: I21346cc195cb3c62e041af8b18770c0940358695
Reviewed-on: https://go-review.googlesource.com/1975
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/gc/walk.c
test/nilcheck.go