Browse Source

autofix: fix unnecessary allocations due to `strings.Index` call (#6806)

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
deepsource-autofix[bot] 3 years ago
parent
commit
b7372b1f32
1 changed files with 4 additions and 4 deletions
  1. 4 4
      internal/markup/markdown.go

+ 4 - 4
internal/markup/markdown.go

@@ -67,8 +67,8 @@ func (r *MarkdownRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {
 		m := CommitPattern.Find(link)
 		if m != nil {
 			m = bytes.TrimSpace(m)
-			i := strings.Index(string(m), "commit/")
-			j := strings.Index(string(m), "#")
+			i := bytes.Index(m, []byte("commit/"))
+			j := bytes.Index(m, []byte("#"))
 			if j == -1 {
 				j = len(m)
 			}
@@ -79,8 +79,8 @@ func (r *MarkdownRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {
 		m = IssueFullPattern.Find(link)
 		if m != nil {
 			m = bytes.TrimSpace(m)
-			i := strings.Index(string(m), "issues/")
-			j := strings.Index(string(m), "#")
+			i := bytes.Index(m, []byte("issues/"))
+			j := bytes.Index(m, []byte("#"))
 			if j == -1 {
 				j = len(m)
 			}