use bytes.Buffer to reduce memory allocation and gc
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package needle
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -48,9 +49,9 @@ func (n *Needle) String() (str string) {
|
||||
return
|
||||
}
|
||||
|
||||
func CreateNeedleFromRequest(r *http.Request, fixJpgOrientation bool, sizeLimit int64) (n *Needle, originalSize int, contentMd5 string, e error) {
|
||||
func CreateNeedleFromRequest(r *http.Request, fixJpgOrientation bool, sizeLimit int64, bytesBuffer *bytes.Buffer) (n *Needle, originalSize int, contentMd5 string, e error) {
|
||||
n = new(Needle)
|
||||
pu, e := ParseUpload(r, sizeLimit)
|
||||
pu, e := ParseUpload(r, sizeLimit, bytesBuffer)
|
||||
if e != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user