1
0
mirror of https://github.com/golang/go synced 2024-11-26 06:38:00 -07:00

cmd/gc: Don't calculate second value in range if it is blank.

Low hanging fruit optimization. Will remove an expensive copy if the range variable is an array.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6564052
This commit is contained in:
Daniel Morsing 2012-09-26 21:10:29 +02:00
parent cca48f1a57
commit 7936ab58f7

View File

@ -72,6 +72,11 @@ typecheckrange(Node *n)
if(n->list->next) if(n->list->next)
v2 = n->list->next->n; v2 = n->list->next->n;
if(isblank(v2)) {
n->list = list1(v1);
v2 = N;
}
if(v1->defn == n) if(v1->defn == n)
v1->type = t1; v1->type = t1;
else if(v1->type != T && assignop(t1, v1->type, &why) == 0) else if(v1->type != T && assignop(t1, v1->type, &why) == 0)