From 7936ab58f7feb25f8c9b367585886d9872a17ad3 Mon Sep 17 00:00:00 2001 From: Daniel Morsing Date: Wed, 26 Sep 2012 21:10:29 +0200 Subject: [PATCH] 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 --- src/cmd/gc/range.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/gc/range.c b/src/cmd/gc/range.c index 459105ee88..741a9ac9a7 100644 --- a/src/cmd/gc/range.c +++ b/src/cmd/gc/range.c @@ -71,6 +71,11 @@ typecheckrange(Node *n) v2 = N; if(n->list->next) v2 = n->list->next->n; + + if(isblank(v2)) { + n->list = list1(v1); + v2 = N; + } if(v1->defn == n) v1->type = t1; -- 2.48.1