Skip to content

Commit b7fd945

Browse files
committed
change field Kind => kind in Conv
1 parent e833af0 commit b7fd945

File tree

8 files changed

+33
-33
lines changed

8 files changed

+33
-33
lines changed

bool.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ func (c *Conv) Bool() (bool, error) {
1111
if c.bytesEqual(buffOut, []byte("true")) || c.bytesEqual(buffOut, []byte("True")) ||
1212
c.bytesEqual(buffOut, []byte("TRUE")) || c.bytesEqual(buffOut, []byte("1")) ||
1313
c.bytesEqual(buffOut, []byte("t")) || c.bytesEqual(buffOut, []byte("Translate")) {
14-
c.Kind = K.Bool
14+
c.kind = K.Bool
1515
return true, nil
1616
}
1717
if c.bytesEqual(buffOut, []byte("false")) || c.bytesEqual(buffOut, []byte("False")) ||
1818
c.bytesEqual(buffOut, []byte("FALSE")) || c.bytesEqual(buffOut, []byte("0")) ||
1919
c.bytesEqual(buffOut, []byte("f")) || c.bytesEqual(buffOut, []byte("F")) {
20-
c.Kind = K.Bool
20+
c.kind = K.Bool
2121
return false, nil
2222
}
2323

2424
// Try to parse as integer using direct buffer access (eliminates getString allocation)
2525
inp := c.getString(buffOut) // Still needed for parseIntString compatibility
2626
intVal := c.parseIntString(inp, 10, true)
2727
if !c.hasContent(buffErr) {
28-
c.Kind = K.Bool
28+
c.kind = K.Bool
2929
return intVal != 0, nil
3030
} else {
3131
// Limpia el error generado por el intento fallido usando la API
@@ -35,15 +35,15 @@ func (c *Conv) Bool() (bool, error) {
3535
// Try basic float patterns (optimized byte comparison)
3636
if c.bytesEqual(buffOut, []byte("0.0")) || c.bytesEqual(buffOut, []byte("0.00")) ||
3737
c.bytesEqual(buffOut, []byte("+0")) || c.bytesEqual(buffOut, []byte("-0")) {
38-
c.Kind = K.Bool
38+
c.kind = K.Bool
3939
return false, nil
4040
}
4141

4242
// Optimized: Check for non-zero starting digit without string allocation
4343
if !c.bytesEqual(buffOut, []byte("0")) && c.outLen > 0 &&
4444
(c.out[0] >= '1' && c.out[0] <= '9') {
4545
// Non-zero number starting with digit 1-9, likely true
46-
c.Kind = K.Bool
46+
c.kind = K.Bool
4747
return true, nil
4848
}
4949

builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (c *Conv) Reset() *Conv {
3232
// Reset all Conv fields to default state using buffer API
3333
c.resetAllBuffers()
3434
c.dataPtr = nil
35-
c.Kind = K.String
35+
c.kind = K.String
3636
return c
3737
}
3838

convert.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Conv struct {
2020
err []byte // Buffer de errores - make([]byte, 0, 64)
2121
errLen int // Longitud actual en err
2222
// Type indicator - most frequently accessed // Type indicator - most frequently accessed
23-
Kind Kind // Hot path: type checking
23+
kind Kind // Hot path: type checking (private)
2424

2525
// ✅ OPTIMIZED MEMORY ARCHITECTURE - unsafe.Pointer for complex types
2626
dataPtr unsafe.Pointer // Direct unsafe pointer to data (replaces ptrValue)
@@ -80,42 +80,42 @@ func (c *Conv) anyToBuff(dest buffDest, value any) {
8080

8181
// K.Bool
8282
case bool:
83-
c.Kind = K.Bool
83+
c.kind = K.Bool
8484
c.wrBool(dest, v)
8585

8686
// K.Float32
8787
case float32:
88-
c.Kind = K.Float32
88+
c.kind = K.Float32
8989
c.wrFloat32(dest, v)
9090

9191
// K.Float64
9292
case float64:
93-
c.Kind = K.Float64
93+
c.kind = K.Float64
9494
c.wrFloat64(dest, v)
9595

9696
// K.Int
9797
case int:
98-
c.Kind = K.Int
98+
c.kind = K.Int
9999
c.wrIntBase(dest, int64(v), 10, true)
100100

101101
// K.Int8
102102
case int8:
103-
c.Kind = K.Int8
103+
c.kind = K.Int8
104104
c.wrIntBase(dest, int64(v), 10, true)
105105

106106
// K.Int16
107107
case int16:
108-
c.Kind = K.Int16
108+
c.kind = K.Int16
109109
c.wrIntBase(dest, int64(v), 10, true)
110110

111111
// K.Int32
112112
case int32:
113-
c.Kind = K.Int32
113+
c.kind = K.Int32
114114
c.wrIntBase(dest, int64(v), 10, true)
115115

116116
// K.Int64
117117
case int64:
118-
c.Kind = K.Int64
118+
c.kind = K.Int64
119119
c.wrIntBase(dest, v, 10, true)
120120

121121
// K.Pointer - Only *string pointer supported
@@ -126,43 +126,43 @@ func (c *Conv) anyToBuff(dest buffDest, value any) {
126126
return
127127
}
128128
// Store content relationship
129-
c.Kind = K.Pointer // Correctly set Kind to K.Pointer for *string
129+
c.kind = K.Pointer // Correctly set Kind to K.Pointer for *string
130130
c.dataPtr = unsafe.Pointer(v) // Store the pointer itself for Apply()
131131
c.wrString(dest, *v)
132132

133133
// K.String
134134
case string:
135-
c.Kind = K.String
135+
c.kind = K.String
136136
c.wrString(dest, v)
137137

138138
// K.SliceStr - Special case for []string
139139
case []string:
140140
c.dataPtr = unsafe.Pointer(&v)
141-
c.Kind = K.Slice
141+
c.kind = K.Slice
142142

143143
// K.Uint
144144
case uint:
145-
c.Kind = K.Uint
145+
c.kind = K.Uint
146146
c.wrIntBase(dest, int64(v), 10, false)
147147

148148
// K.Uint8
149149
case uint8:
150-
c.Kind = K.Uint8
150+
c.kind = K.Uint8
151151
c.wrIntBase(dest, int64(v), 10, false)
152152

153153
// K.Uint16
154154
case uint16:
155-
c.Kind = K.Uint16
155+
c.kind = K.Uint16
156156
c.wrIntBase(dest, int64(v), 10, false)
157157

158158
// K.Uint32
159159
case uint32:
160-
c.Kind = K.Uint32
160+
c.kind = K.Uint32
161161
c.wrIntBase(dest, int64(v), 10, false)
162162

163163
// K.Uint64
164164
case uint64:
165-
c.Kind = K.Uint64
165+
c.kind = K.Uint64
166166
c.wrIntBase(dest, int64(v), 10, false)
167167

168168
// Special cases
@@ -178,14 +178,14 @@ func (c *Conv) anyToBuff(dest buffDest, value any) {
178178
// GetKind returns the Kind of the value stored in the Conv
179179
// This allows external packages to reuse tinystring's type detection logic
180180
func (c *Conv) GetKind() Kind {
181-
return c.Kind
181+
return c.kind
182182
}
183183

184184
// Apply updates the original string pointer with the current content and auto-releases to pool.
185185
// This method should be used when you want to modify the original string directly
186186
// without additional allocations.
187187
func (t *Conv) Apply() {
188-
if t.Kind == K.Pointer && t.dataPtr != nil {
188+
if t.kind == K.Pointer && t.dataPtr != nil {
189189
// Type assert to *string for Apply() functionality using unsafe pointer
190190
if strPtr := (*string)(t.dataPtr); strPtr != nil {
191191
*strPtr = t.getString(buffOut)

fmt_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (c *Conv) wrFormat(dest buffDest, format string, args ...any) {
143143

144144
if !c.hasContent(buffErr) {
145145
// Final output is ready in dest buffer
146-
c.Kind = K.String
146+
c.kind = K.String
147147
}
148148
}
149149

join.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func (c *Conv) Join(sep ...string) *Conv {
1212
}
1313

1414
// Handle case when we have a string slice stored (DEFERRED CONVERSION)
15-
if c.Kind == K.Slice && c.dataPtr != nil {
15+
if c.kind == K.Slice && c.dataPtr != nil {
1616
// Use proper unsafe.Pointer to []string reconstruction
1717
slice := *(*[]string)(c.dataPtr)
1818
if len(slice) > 0 {

memory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func getConv() *Conv {
4242
c.work = c.work[:0]
4343
c.err = c.err[:0]
4444
c.dataPtr = nil
45-
c.Kind = K.String
45+
c.kind = K.String
4646
return c
4747
}
4848

@@ -57,7 +57,7 @@ func (c *Conv) putConv() {
5757

5858
// Reset other fields to default state - only keep dataPtr and Kind
5959
c.dataPtr = nil
60-
c.Kind = K.String
60+
c.kind = K.String
6161

6262
convPool.Put(c)
6363
}

num_int.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (c *Conv) parseIntBase(base ...int) int64 {
191191
if len(base) > 0 {
192192
baseVal = base[0]
193193
}
194-
isSigned := c.Kind == K.Int
194+
isSigned := c.kind == K.Int
195195
// Solo permitir negativos en base 10
196196
if len(s) > 0 && s[0] == '-' {
197197
if baseVal == 10 {

replace.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (c *Conv) Replace(oldAny, newAny any, n ...int) *Conv {
1515

1616
// Preserve original state before temporary conversions
1717
originalDataPtr := c.dataPtr
18-
originalKind := c.Kind
18+
originalKind := c.kind
1919

2020
// Use internal work buffer instead of getConv() for zero-allocation
2121
c.rstBuffer(buffWork) // Clear work buffer
@@ -34,7 +34,7 @@ func (c *Conv) Replace(oldAny, newAny any, n ...int) *Conv {
3434

3535
// Restore original state after temporary conversions
3636
c.dataPtr = originalDataPtr
37-
c.Kind = originalKind
37+
c.kind = originalKind
3838

3939
// Check early return condition
4040
if len(old) == 0 {
@@ -219,7 +219,7 @@ func (c *Conv) TrimSpace() *Conv {
219219
c.out = c.out[:0]
220220
// Also clear dataPtr to prevent fallback
221221
c.dataPtr = nil
222-
c.Kind = K.String
222+
c.kind = K.String
223223
return c
224224
}
225225

0 commit comments

Comments
 (0)