Skip to content

Commit 8405773

Browse files
committed
fix: rename IsNull method to isNull for consistency in ScaledDecimal
1 parent f3222af commit 8405773

File tree

2 files changed

+5
-38
lines changed

2 files changed

+5
-38
lines changed

buffer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ func (b *buffer) Float64Column(name string, val float64) *buffer {
574574
}
575575

576576
func (b *buffer) DecimalColumnScaled(name string, val ScaledDecimal) *buffer {
577-
if val.IsNull() {
577+
if val.isNull() {
578578
// Don't write null decimals
579579
return b
580580
}
@@ -634,7 +634,7 @@ func (b *buffer) DecimalColumnShopspring(name string, val ShopspringDecimal) *bu
634634
b.lastErr = err
635635
return b
636636
}
637-
if dec.IsNull() {
637+
if dec.isNull() {
638638
// Don't write null decimals
639639
return b
640640
}

decimal.go

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,13 @@ func NewDecimalFromInt64(unscaled int64, scale uint32) ScaledDecimal {
100100
}
101101
}
102102

103-
// IsNull reports whether the decimal represents NULL.
104-
func (d ScaledDecimal) IsNull() bool {
103+
// isNull reports whether the decimal represents NULL.
104+
func (d ScaledDecimal) isNull() bool {
105105
return d.offset >= 32
106106
}
107107

108-
// Scale returns the decimal scale.
109-
func (d ScaledDecimal) Scale() uint32 {
110-
return d.scale
111-
}
112-
113-
// UnscaledValue returns a copy of the unscaled integer value.
114-
// For NULL decimals it returns nil.
115-
func (d ScaledDecimal) UnscaledValue() *big.Int {
116-
if d.IsNull() {
117-
return nil
118-
}
119-
return twosComplementToBigInt(d.unscaled[d.offset:])
120-
}
121-
122108
func (d ScaledDecimal) ensureValidScale() error {
123-
if d.IsNull() {
109+
if d.isNull() {
124110
return nil
125111
}
126112
if d.scale > maxDecimalScale {
@@ -233,25 +219,6 @@ func trimTwosComplement(bytes []byte) int {
233219
return i
234220
}
235221

236-
func twosComplementToBigInt(bytes []byte) *big.Int {
237-
if len(bytes) == 0 {
238-
return big.NewInt(0)
239-
}
240-
if bytes[0]&0x80 == 0 {
241-
return new(big.Int).SetBytes(bytes)
242-
}
243-
244-
inverted := make([]byte, len(bytes))
245-
for i := range bytes {
246-
inverted[i] = ^bytes[i]
247-
}
248-
249-
magnitude := new(big.Int).SetBytes(inverted)
250-
magnitude.Add(magnitude, big.NewInt(1))
251-
magnitude.Neg(magnitude)
252-
return magnitude
253-
}
254-
255222
// validateDecimalText checks that the provided string is a valid decimal representation.
256223
// It accepts numeric digits, optional sign, decimal point, exponent (e/E) and NaN/Infinity tokens.
257224
func validateDecimalText(text string) error {

0 commit comments

Comments
 (0)