Avoid repeatedly growning decoded values slices
parent
778000435a
commit
3d12c62121
|
@ -407,6 +407,14 @@ func DecodeFloatBlock(block []byte, a *[]FloatValue) ([]FloatValue, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
sz := CountTimestamps(tb)
|
||||
|
||||
if cap(*a) < sz {
|
||||
*a = make([]FloatValue, sz)
|
||||
} else {
|
||||
*a = (*a)[:sz]
|
||||
}
|
||||
|
||||
tdec := timeDecoderPool.Get(0).(*TimeDecoder)
|
||||
vdec := floatDecoderPool.Get(0).(*FloatDecoder)
|
||||
|
||||
|
@ -537,6 +545,14 @@ func DecodeBooleanBlock(block []byte, a *[]BooleanValue) ([]BooleanValue, error)
|
|||
return nil, err
|
||||
}
|
||||
|
||||
sz := CountTimestamps(tb)
|
||||
|
||||
if cap(*a) < sz {
|
||||
*a = make([]BooleanValue, sz)
|
||||
} else {
|
||||
*a = (*a)[:sz]
|
||||
}
|
||||
|
||||
tdec := timeDecoderPool.Get(0).(*TimeDecoder)
|
||||
vdec := booleanDecoderPool.Get(0).(*BooleanDecoder)
|
||||
|
||||
|
@ -655,6 +671,14 @@ func DecodeIntegerBlock(block []byte, a *[]IntegerValue) ([]IntegerValue, error)
|
|||
return nil, err
|
||||
}
|
||||
|
||||
sz := CountTimestamps(tb)
|
||||
|
||||
if cap(*a) < sz {
|
||||
*a = make([]IntegerValue, sz)
|
||||
} else {
|
||||
*a = (*a)[:sz]
|
||||
}
|
||||
|
||||
tdec := timeDecoderPool.Get(0).(*TimeDecoder)
|
||||
vdec := integerDecoderPool.Get(0).(*IntegerDecoder)
|
||||
|
||||
|
@ -773,6 +797,14 @@ func DecodeUnsignedBlock(block []byte, a *[]UnsignedValue) ([]UnsignedValue, err
|
|||
return nil, err
|
||||
}
|
||||
|
||||
sz := CountTimestamps(tb)
|
||||
|
||||
if cap(*a) < sz {
|
||||
*a = make([]UnsignedValue, sz)
|
||||
} else {
|
||||
*a = (*a)[:sz]
|
||||
}
|
||||
|
||||
tdec := timeDecoderPool.Get(0).(*TimeDecoder)
|
||||
vdec := integerDecoderPool.Get(0).(*IntegerDecoder)
|
||||
|
||||
|
@ -892,6 +924,14 @@ func DecodeStringBlock(block []byte, a *[]StringValue) ([]StringValue, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
sz := CountTimestamps(tb)
|
||||
|
||||
if cap(*a) < sz {
|
||||
*a = make([]StringValue, sz)
|
||||
} else {
|
||||
*a = (*a)[:sz]
|
||||
}
|
||||
|
||||
tdec := timeDecoderPool.Get(0).(*TimeDecoder)
|
||||
vdec := stringDecoderPool.Get(0).(*StringDecoder)
|
||||
|
||||
|
|
Loading…
Reference in New Issue