MCPcopy Create free account
hub / github.com/google/pprof / rightPad

Function rightPad

internal/report/source.go:1087–1110  ·  view source on GitHub ↗

rightPad pads the input with spaces on the right-hand-side to make it have at least width n. It treats tabs as enough spaces that lead to the next 8-aligned tab-stop.

(s string, n int)

Source from the content-addressed store, hash-verified

1085// at least width n. It treats tabs as enough spaces that lead to the next
1086// 8-aligned tab-stop.
1087func rightPad(s string, n int) string {
1088 var str strings.Builder
1089
1090 // Convert tabs to spaces as we go so padding works regardless of what prefix
1091 // is placed before the result.
1092 column := 0
1093 for _, c := range s {
1094 column++
1095 if c == '\t' {
1096 str.WriteRune(' ')
1097 for column%8 != 0 {
1098 column++
1099 str.WriteRune(' ')
1100 }
1101 } else {
1102 str.WriteRune(c)
1103 }
1104 }
1105 for column < n {
1106 column++
1107 str.WriteRune(' ')
1108 }
1109 return str.String()
1110}
1111
1112func canonicalizeFileName(fname string) string {
1113 fname = strings.TrimPrefix(fname, "/proc/self/cwd/")

Callers 2

makeWebListInstructionsFunction · 0.85
TestRightPadFunction · 0.85

Calls 1

StringMethod · 0.65

Tested by 1

TestRightPadFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…