mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 00:47:28 +01:00
lang: add if.likely and if.unlikely
This commit is contained in:
1 parent
1acd74482a
commit
8916f1b6ea
5 files changed
+32
-8
No files matched your search
@@ -430,12 +430,19 @@ func (g *gen) writeStatementIf(b *buffer, n *a.If, depth uint32) error {
|
||||
}
|
||||
|
||||
for {
|
||||
prefix, suffix := "", ""
|
||||
switch n.Likelihood() {
|
||||
case t.IDLikely:
|
||||
prefix, suffix = "WUFFS_BASE__LIKELY(", ")"
|
||||
case t.IDUnlikely:
|
||||
prefix, suffix = "WUFFS_BASE__UNLIKELY(", ")"
|
||||
}
|
||||
condition := buffer(nil)
|
||||
if err := g.writeExpr(&condition, n.Condition(), false, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
// Calling trimParens avoids clang's -Wparentheses-equality warning.
|
||||
b.printf("if (%s) {\n", trimParens(condition))
|
||||
b.printf("if (%s%s%s) {\n", prefix, trimParens(condition), suffix)
|
||||
for _, o := range n.BodyIfTrue() {
|
||||
if err := g.writeStatement(b, o, depth); err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user