pkg/escape: Preallocate output in Unescape
Preallocating the capacity of the output is faster and uses less memory than letting append() do its own (over)allocation.pull/9101/head
parent
1b2301cc15
commit
b0e871876a
|
@ -78,7 +78,11 @@ func Unescape(in []byte) []byte {
|
|||
|
||||
i := 0
|
||||
inLen := len(in)
|
||||
var out []byte
|
||||
|
||||
// The output size will be no more than inLen. Preallocating the
|
||||
// capacity of the output is faster and uses less memory than
|
||||
// letting append() do its own (over)allocation.
|
||||
out := make([]byte, 0, inLen)
|
||||
|
||||
for {
|
||||
if i >= inLen {
|
||||
|
|
Loading…
Reference in New Issue