Merge pull request #171 from moorereason/unused-buf

Remove unnecessary buffer
This commit is contained in:
Yusuke Inuzuka 2020-12-26 18:01:51 +09:00 committed by GitHub
commit 033db7dd82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -290,20 +290,17 @@ func (s *linkParser) parseLink(parent ast.Node, last *linkLabelState, block text
func parseLinkDestination(block text.Reader) ([]byte, bool) { func parseLinkDestination(block text.Reader) ([]byte, bool) {
block.SkipSpaces() block.SkipSpaces()
line, _ := block.PeekLine() line, _ := block.PeekLine()
buf := []byte{}
if block.Peek() == '<' { if block.Peek() == '<' {
i := 1 i := 1
for i < len(line) { for i < len(line) {
c := line[i] c := line[i]
if c == '\\' && i < len(line)-1 && util.IsPunct(line[i+1]) { if c == '\\' && i < len(line)-1 && util.IsPunct(line[i+1]) {
buf = append(buf, '\\', line[i+1])
i += 2 i += 2
continue continue
} else if c == '>' { } else if c == '>' {
block.Advance(i + 1) block.Advance(i + 1)
return line[1:i], true return line[1:i], true
} }
buf = append(buf, c)
i++ i++
} }
return nil, false return nil, false
@ -313,7 +310,6 @@ func parseLinkDestination(block text.Reader) ([]byte, bool) {
for i < len(line) { for i < len(line) {
c := line[i] c := line[i]
if c == '\\' && i < len(line)-1 && util.IsPunct(line[i+1]) { if c == '\\' && i < len(line)-1 && util.IsPunct(line[i+1]) {
buf = append(buf, '\\', line[i+1])
i += 2 i += 2
continue continue
} else if c == '(' { } else if c == '(' {
@ -326,7 +322,6 @@ func parseLinkDestination(block text.Reader) ([]byte, bool) {
} else if util.IsSpace(c) { } else if util.IsSpace(c) {
break break
} }
buf = append(buf, c)
i++ i++
} }
block.Advance(i) block.Advance(i)