diff options
author | 2025-03-05 10:26:04 -0800 | |
---|---|---|
committer | 2025-03-05 10:26:04 -0800 | |
commit | 2006e89ade5f24a5edcc7ed1ec9dc2f74abe7415 (patch) | |
tree | 862b58cbbfc80e55197e19d07a871c7e55d84b10 | |
parent | de3a5c4be8aff15998cbf898e06fcc4679fe911f (diff) |
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
-rw-r--r-- | android/rule_builder.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/android/rule_builder.go b/android/rule_builder.go index db56c3f29..ea6aaa4c4 100644 --- a/android/rule_builder.go +++ b/android/rule_builder.go @@ -1187,7 +1187,11 @@ func (c *RuleBuilderCommand) Text(text string) *RuleBuilderCommand { // 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 |