diff options
| author | Shulhan <ms@kilabit.info> | 2024-08-15 23:30:50 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-08-16 00:30:49 +0700 |
| commit | e9b1dce76d78e6b26afa57de7469bf262a53790f (patch) | |
| tree | 4f1fd05e6300bc417e4b078438b928c70bbea61b /document_parser.go | |
| parent | 836385a4ad7bc9a914c9a8544901518f0a64f2ed (diff) | |
| download | asciidoctor-go-e9b1dce76d78e6b26afa57de7469bf262a53790f.tar.xz | |
all: remove unnecessary TrimRight
Each lines to be parsed has been trimmed on the first load, so
there is no need to do it again, on some cases.
Diffstat (limited to 'document_parser.go')
| -rw-r--r-- | document_parser.go | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/document_parser.go b/document_parser.go index 96c37db..3a0a2f8 100644 --- a/document_parser.go +++ b/document_parser.go @@ -601,7 +601,7 @@ func (docp *documentParser) parseBlock(parent *element, term int) { continue case elKindBlockImage: - var lineImage = bytes.TrimRight(line[7:], " \t") + var lineImage = line[7:] if el.parseBlockImage(docp.doc, lineImage) { el.kind = docp.kind line = nil @@ -1606,8 +1606,6 @@ func (docp *documentParser) skipCommentAndEmptyLine() (line []byte, ok bool) { func (docp *documentParser) whatKindOfLine(line []byte) (spaces, got []byte) { docp.kind = lineKindText - line = bytes.TrimRight(line, " \f\n\r\t\v") - // All of the comparison MUST be in order. if len(line) == 0 { @@ -1725,16 +1723,15 @@ func (docp *documentParser) whatKindOfLine(line []byte) (spaces, got []byte) { docp.kind = lineKindAttribute case '[': var ( - newline = bytes.TrimRight(line, " \t") - l = len(newline) + l = len(line) ) - if newline[l-1] != ']' { + if line[l-1] != ']' { return nil, line } if l >= 5 { // [[x]] - if newline[1] == '[' && newline[l-2] == ']' { + if line[1] == '[' && line[l-2] == ']' { docp.kind = lineKindID return nil, line } |
