diff options
author | Jamie Liu <jamieliu@google.com> | 2021-01-20 15:54:51 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-01-20 15:56:40 -0800 |
commit | 9af6150b5e36bcc731db6f4693fe8e9c5848a5e3 (patch) | |
tree | 7fc45035c78846d6b1520fc32024269609fb97f0 /pkg/sentry | |
parent | 2865166403896a668167678ba0a8c2ef24268ca0 (diff) |
Remove string allocation from strings.Repeat() in /proc/[pid]/maps.
PiperOrigin-RevId: 352894106
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/mm/procfs.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/pkg/sentry/mm/procfs.go b/pkg/sentry/mm/procfs.go index 6efe5102b..73bfbea49 100644 --- a/pkg/sentry/mm/procfs.go +++ b/pkg/sentry/mm/procfs.go @@ -17,7 +17,6 @@ package mm import ( "bytes" "fmt" - "strings" "gvisor.dev/gvisor/pkg/context" "gvisor.dev/gvisor/pkg/sentry/fs/proc/seqfile" @@ -165,12 +164,12 @@ func (mm *MemoryManager) appendVMAMapsEntryLocked(ctx context.Context, vseg vmaI } if s != "" { // Per linux, we pad until the 74th character. - if pad := 73 - lineLen; pad > 0 { - b.WriteString(strings.Repeat(" ", pad)) + for pad := 73 - lineLen; pad > 0; pad-- { + b.WriteByte(' ') } b.WriteString(s) } - b.WriteString("\n") + b.WriteByte('\n') } // ReadSmapsDataInto is called by fsimpl/proc.smapsData.Generate to |