Optimize RuleBuilderCommand.Textf()
Just a minor optimization that I noticed could be made. Other
functions that call .Text(a+b) could also be optimized to not create
the intermediate string, but just go with this for now.
Test: Presubmits
Change-Id: I72bfabcb484d7e1a33db0495b52834668231ee2a
diff --git a/android/rule_builder.go b/android/rule_builder.go
index db56c3f..ea6aaa4 100644
--- a/android/rule_builder.go
+++ b/android/rule_builder.go
@@ -1187,7 +1187,11 @@
// Textf adds the specified formatted text to the command line. The text should not contain input or output paths or
// the rule will not have them listed in its dependencies or outputs.
func (c *RuleBuilderCommand) Textf(format string, a ...interface{}) *RuleBuilderCommand {
- return c.Text(fmt.Sprintf(format, a...))
+ if c.buf.Len() > 0 {
+ c.buf.WriteByte(' ')
+ }
+ fmt.Fprintf(&c.buf, format, a...)
+ return c
}
// Flag adds the specified raw text to the command line. The text should not contain input or output paths or the