asm/amd64: optimizes initializeNodesForEncoding (#1393)

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2023-04-23 16:22:37 -07:00
committed by GitHub
parent 601db82f8e
commit c6c46114ef

View File

@@ -471,18 +471,10 @@ func (a *AssemblerImpl) initializeNodesForEncoding() {
target.forwardJumpTarget = true
}
// We add this node `n` into the end of the linked list (.forwardJumpOrigins)
// beginning from the `target`.
tail := target
for {
if tail.forwardJumpOrigins == nil {
// If we found the tail, let's append it.
tail.forwardJumpOrigins = n
break
} else {
tail = tail.forwardJumpOrigins
}
}
// We add this node `n` into the end of the linked list (.forwardJumpOrigins) beginning from the `target.forwardJumpOrigins`.
// Insert the current `n` as the head of the list.
n.forwardJumpOrigins = target.forwardJumpOrigins
target.forwardJumpOrigins = n
}
}
}