@@ -133,8 +133,8 @@ func (p *Packfile) getObjectSize(h *ObjectHeader) (int64, error) {
133
133
return h .Length , nil
134
134
case plumbing .REFDeltaObject , plumbing .OFSDeltaObject :
135
135
buf := bufPool .Get ().(* bytes.Buffer )
136
- buf .Reset ()
137
136
defer bufPool .Put (buf )
137
+ buf .Reset ()
138
138
139
139
if _ , _ , err := p .s .NextObject (buf ); err != nil {
140
140
return 0 , err
@@ -222,11 +222,11 @@ func (p *Packfile) getNextObject(h *ObjectHeader, hash plumbing.Hash) (plumbing.
222
222
// optimization only if the expanded version of the object still meets
223
223
// the small object threshold condition.
224
224
buf := bufPool .Get ().(* bytes.Buffer )
225
+ defer bufPool .Put (buf )
225
226
buf .Reset ()
226
227
if _ , _ , err := p .s .NextObject (buf ); err != nil {
227
228
return nil , err
228
229
}
229
- defer bufPool .Put (buf )
230
230
231
231
size = p .getDeltaObjectSize (buf )
232
232
if size <= smallObjectThreshold {
@@ -321,12 +321,12 @@ func (p *Packfile) fillRegularObjectContent(obj plumbing.EncodedObject) error {
321
321
322
322
func (p * Packfile ) fillREFDeltaObjectContent (obj plumbing.EncodedObject , ref plumbing.Hash ) error {
323
323
buf := bufPool .Get ().(* bytes.Buffer )
324
+ defer bufPool .Put (buf )
324
325
buf .Reset ()
325
326
_ , _ , err := p .s .NextObject (buf )
326
327
if err != nil {
327
328
return err
328
329
}
329
- defer bufPool .Put (buf )
330
330
331
331
return p .fillREFDeltaObjectContentWithBuffer (obj , ref , buf )
332
332
}
@@ -351,12 +351,12 @@ func (p *Packfile) fillREFDeltaObjectContentWithBuffer(obj plumbing.EncodedObjec
351
351
352
352
func (p * Packfile ) fillOFSDeltaObjectContent (obj plumbing.EncodedObject , offset int64 ) error {
353
353
buf := bufPool .Get ().(* bytes.Buffer )
354
+ defer bufPool .Put (buf )
354
355
buf .Reset ()
355
356
_ , _ , err := p .s .NextObject (buf )
356
357
if err != nil {
357
358
return err
358
359
}
359
- defer bufPool .Put (buf )
360
360
361
361
return p .fillOFSDeltaObjectContentWithBuffer (obj , offset , buf )
362
362
}
0 commit comments