Commit 7936ab58 authored by Daniel Morsing's avatar Daniel Morsing

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
parent cca48f1a
...@@ -71,6 +71,11 @@ typecheckrange(Node *n) ...@@ -71,6 +71,11 @@ typecheckrange(Node *n)
v2 = N; v2 = 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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment