|
@@ -1,6 +1,9 @@
|
|
|
package sarama
|
|
|
|
|
|
-import "encoding/binary"
|
|
|
+import (
|
|
|
+ "encoding/binary"
|
|
|
+ "sync"
|
|
|
+)
|
|
|
|
|
|
|
|
|
type lengthField struct {
|
|
@@ -8,6 +11,20 @@ type lengthField struct {
|
|
|
length int32
|
|
|
}
|
|
|
|
|
|
+var lengthFieldPool = sync.Pool{}
|
|
|
+
|
|
|
+func acquireLengthField() *lengthField {
|
|
|
+ val := lengthFieldPool.Get()
|
|
|
+ if val != nil {
|
|
|
+ return val.(*lengthField)
|
|
|
+ }
|
|
|
+ return &lengthField{}
|
|
|
+}
|
|
|
+
|
|
|
+func releaseLengthField(m *lengthField) {
|
|
|
+ lengthFieldPool.Put(m)
|
|
|
+}
|
|
|
+
|
|
|
func (l *lengthField) decode(pd packetDecoder) error {
|
|
|
var err error
|
|
|
l.length, err = pd.getInt32()
|