pkg: refactor to buf.WriteString() (#3769)

This commit is contained in:
Oleksandr Redko 2024-07-11 18:06:51 +03:00 committed by GitHub
parent a3e4a41468
commit ef13067401
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 8 deletions

@ -50,12 +50,12 @@ func spliceDocs(docpath string, docs []byte, outpath string) {
footer := v[1] footer := v[1]
outbuf := bytes.NewBuffer(make([]byte, 0, len(header)+len(docs)+len(footer)+len(startOfToc)+len(endOfToc)+1)) outbuf := bytes.NewBuffer(make([]byte, 0, len(header)+len(docs)+len(footer)+len(startOfToc)+len(endOfToc)+1))
outbuf.Write([]byte(header)) outbuf.WriteString(header)
outbuf.Write([]byte(startOfToc)) outbuf.WriteString(startOfToc)
outbuf.WriteByte('\n') outbuf.WriteByte('\n')
outbuf.Write(docs) outbuf.Write(docs)
outbuf.Write([]byte(endOfToc)) outbuf.WriteString(endOfToc)
outbuf.Write([]byte(footer)) outbuf.WriteString(footer)
if outpath != "-" { if outpath != "-" {
err = os.WriteFile(outpath, outbuf.Bytes(), 0o664) err = os.WriteFile(outpath, outbuf.Bytes(), 0o664)

@ -137,7 +137,7 @@ func (b *Builder) Attr(attr dwarf.Attr, val interface{}) dwarf.Offset {
switch x := val.(type) { switch x := val.(type) {
case string: case string:
tag.form = append(tag.form, DW_FORM_string) tag.form = append(tag.form, DW_FORM_string)
b.info.Write([]byte(x)) b.info.WriteString(x)
b.info.WriteByte(0) b.info.WriteByte(0)
case uint8: case uint8:
tag.form = append(tag.form, DW_FORM_data1) tag.form = append(tag.form, DW_FORM_data1)

@ -273,7 +273,7 @@ func (t *Target) dumpThreadNotes(notes []elfwriter.Note, state *DumpState, th Th
for _, reg := range regsv { for _, reg := range regsv {
binary.Write(buf, binary.LittleEndian, uint16(len(reg.Name))) binary.Write(buf, binary.LittleEndian, uint16(len(reg.Name)))
buf.Write([]byte(reg.Name)) buf.WriteString(reg.Name)
if reg.Reg.Bytes != nil { if reg.Reg.Bytes != nil {
binary.Write(buf, binary.LittleEndian, uint16(len(reg.Reg.Bytes))) binary.Write(buf, binary.LittleEndian, uint16(len(reg.Reg.Bytes)))
buf.Write(reg.Reg.Bytes) buf.Write(reg.Reg.Bytes)

@ -258,7 +258,7 @@ func rrStderrParser(stderr io.ReadCloser, initch chan<- rrInit, quiet bool) {
} }
if !quiet { if !quiet {
os.Stderr.Write([]byte(line)) os.Stderr.WriteString(line)
} }
} }

@ -3127,7 +3127,7 @@ func (c *Commands) onCmd(t *Term, ctx callContext, argstr string) error {
_ = os.Remove(f.Name()) _ = os.Remove(f.Name())
}() }()
attrs := formatBreakpointAttrs("", ctx.Breakpoint, true) attrs := formatBreakpointAttrs("", ctx.Breakpoint, true)
_, err = f.Write([]byte(strings.Join(attrs, "\n"))) _, err = f.WriteString(strings.Join(attrs, "\n"))
if err != nil { if err != nil {
return err return err
} }