mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
perf(reader): shrink the json detection buffer
There is no need to allocate half a kilobyte of memory only check that a buffer starts with a bunch of spaces and a `{`, 32b should be more than enough. Also, no need to allocate it on the heap, having it on the stack works perfectly.
This commit is contained in:
parent
63891501e5
commit
d6d18a2d61
1 changed files with 2 additions and 1 deletions
|
@ -22,7 +22,8 @@ const (
|
|||
|
||||
// DetectFeedFormat tries to guess the feed format from input data.
|
||||
func DetectFeedFormat(r io.ReadSeeker) (string, string) {
|
||||
data := make([]byte, 512)
|
||||
var dataArray = [32]byte{}
|
||||
data := dataArray[:]
|
||||
r.Read(data)
|
||||
|
||||
if bytes.HasPrefix(bytes.TrimSpace(data), []byte("{")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue