Commit 2d64bab1 authored by Shenghou Ma's avatar Shenghou Ma Committed by Russ Cox

5l: optimize the common case in patch()

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