A new implementation for body tag on html detection#14402
Closed
lunny wants to merge 1 commit into
Closed
Conversation
6543
approved these changes
Jan 19, 2021
zeripath
reviewed
Jan 19, 2021
Comment on lines
350
to
+353
| // Create buffer in which the data will be placed again. We know that the | ||
| // length will be at least that of res; to spare a few alloc+copy, we | ||
| // reuse res, resetting its length to 0. | ||
| buf := bytes.NewBuffer(res[:0]) | ||
| buf := bytes.NewBuffer([]byte{}) |
Contributor
There was a problem hiding this comment.
https://golang.org/pkg/bytes/#NewBuffer
NewBuffer creates and initializes a new Buffer using buf as its initial contents. The new Buffer takes ownership of buf, and the caller should not use buf after this call. NewBuffer is intended to prepare a Buffer to read existing data. It can also be used to set the initial size of the internal buffer for writing. To do that, buf should have the desired capacity but a length of zero.
In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer.
Suggested change
| // Create buffer in which the data will be placed again. We know that the | |
| // length will be at least that of res; to spare a few alloc+copy, we | |
| // reuse res, resetting its length to 0. | |
| buf := bytes.NewBuffer(res[:0]) | |
| buf := bytes.NewBuffer([]byte{}) | |
| // Create buffer in which the data will be placed again. | |
| buf := new(bytes.Buffer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduced a new implementation to detect body tag on a html buffer.