Skip to content

Commit

Permalink
Reduce some allocations in type conversion (#26772)
Browse files Browse the repository at this point in the history
  • Loading branch information
harryzcy committed Aug 28, 2023
1 parent 4803766 commit ac2f8c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/log/event_writer_base.go
Expand Up @@ -90,7 +90,7 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) {

if exprRegexp != nil {
fileLineCaller := fmt.Sprintf("%s:%d:%s", event.Origin.Filename, event.Origin.Line, event.Origin.Caller)
matched := exprRegexp.Match([]byte(fileLineCaller)) || exprRegexp.Match([]byte(event.Origin.MsgSimpleText))
matched := exprRegexp.MatchString(fileLineCaller) || exprRegexp.MatchString(event.Origin.MsgSimpleText)
if !matched {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion services/packages/rpm/repository.go
Expand Up @@ -232,7 +232,7 @@ func buildRepomd(pv *packages_model.PackageVersion, ownerID int64, data []*repoD
}

var buf bytes.Buffer
buf.Write([]byte(xml.Header))
buf.WriteString(xml.Header)
if err := xml.NewEncoder(&buf).Encode(&Repomd{
Xmlns: "http://linux.duke.edu/metadata/repo",
XmlnsRpm: "http://linux.duke.edu/metadata/rpm",
Expand Down
4 changes: 2 additions & 2 deletions services/pull/pull.go
Expand Up @@ -755,11 +755,11 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ
}

for _, author := range authors {
if _, err := stringBuilder.Write([]byte("Co-authored-by: ")); err != nil {
if _, err := stringBuilder.WriteString("Co-authored-by: "); err != nil {
log.Error("Unable to write to string builder Error: %v", err)
return ""
}
if _, err := stringBuilder.Write([]byte(author)); err != nil {
if _, err := stringBuilder.WriteString(author); err != nil {
log.Error("Unable to write to string builder Error: %v", err)
return ""
}
Expand Down

0 comments on commit ac2f8c9

Please sign in to comment.