]> Cypherpunks repositories - gostls13.git/commitdiff
5l: optimize the common case in patch()
authorShenghou Ma <minux.ma@gmail.com>
Tue, 31 Jan 2012 15:59:34 +0000 (10:59 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 31 Jan 2012 15:59:34 +0000 (10:59 -0500)
    If p->to.sym->text is non-nil, then no need to search for sym->value.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5601046

src/cmd/5l/pass.c

index c430494597cd09ba4bf4750bb68e9497bc5bc560..0f2afbd850de0365c78646ca9a4715ce7655e337 100644 (file)
@@ -213,6 +213,8 @@ patch(void)
                        if((a == ABL || a == ABX || a == AB || a == ARET) &&
                           p->to.type != D_BRANCH && p->to.sym != S) {
                                s = p->to.sym;
+                               if(s->text == nil)
+                                       continue;
                                switch(s->type) {
                                default:
                                        diag("undefined: %s", s->name);
@@ -222,7 +224,8 @@ patch(void)
                                case STEXT:
                                        p->to.offset = s->value;
                                        p->to.type = D_BRANCH;
-                                       break;
+                                       p->cond = s->text;
+                                       continue;
                                }
                        }
                        if(p->to.type != D_BRANCH)