Skip to content

Commit e20a9fd

Browse files
committed
Optimization (fndome#24)
1 parent e5bf4cb commit e20a9fd

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

bb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ type Bb struct {
2020
op string
2121
key string
2222
value interface{}
23-
subs []*Bb
23+
subs []Bb
2424
}

builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func NewBuilder(poOrNil Po) *Builder {
3939

4040
func newBuilder() *Builder {
4141
b := new(Builder)
42-
b.bbs = []*Bb{}
42+
b.bbs = []Bb{}
4343
return b
4444
}
4545

builder_x.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ type BuilderX struct {
3030
resultKeys []string
3131
sbs []*SourceBuilder
3232
svs []interface{}
33-
havings []*Bb
33+
havings []Bb
3434
groupBys []string
3535
isWithoutOptimization bool
3636
}
3737

3838
func NewBuilderX(po Po, alia string) *BuilderX {
3939
x := new(BuilderX)
40-
x.bbs = []*Bb{}
40+
x.bbs = []Bb{}
4141
x.sbs = []*SourceBuilder{}
4242
if po != nil {
4343
var sb = SourceBuilder{
@@ -92,7 +92,7 @@ func (x *BuilderX) Having(op Op, k string, v interface{}) *BuilderX {
9292
key: k,
9393
value: v,
9494
}
95-
x.havings = append(x.havings, &bb)
95+
x.havings = append(x.havings, bb)
9696
return x
9797
}
9898

condition_builder.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ package sqlxb
1919
import "time"
2020

2121
type ConditionBuilder struct {
22-
bbs []*Bb
22+
bbs []Bb
2323
}
2424

2525
type BoolFunc func() bool
2626

2727
func SubCondition() *ConditionBuilder {
2828
c := new(ConditionBuilder)
29-
c.bbs = []*Bb{}
29+
c.bbs = []Bb{}
3030
return c
3131
}
3232

@@ -36,7 +36,7 @@ func (builder *ConditionBuilder) X(k string, vs ...interface{}) *ConditionBuilde
3636
key: k,
3737
value: vs,
3838
}
39-
builder.bbs = append(builder.bbs, &bb)
39+
builder.bbs = append(builder.bbs, bb)
4040
return builder
4141
}
4242

@@ -83,7 +83,7 @@ func (builder *ConditionBuilder) doIn(p string, k string, vs... interface{}) *Co
8383
key: k,
8484
value: &ss,
8585
}
86-
builder.bbs = append(builder.bbs, &bb)
86+
builder.bbs = append(builder.bbs, bb)
8787

8888
return builder
8989
}
@@ -95,7 +95,7 @@ func (builder *ConditionBuilder) doLike(p string, k string, v string) *Condition
9595
key: k,
9696
value: v,
9797
}
98-
builder.bbs = append(builder.bbs, &bb)
98+
builder.bbs = append(builder.bbs, bb)
9999

100100
return builder
101101
}
@@ -136,7 +136,7 @@ func (builder *ConditionBuilder) addBb(op string, key string, v interface{}) *Co
136136
key: key,
137137
value: v,
138138
}
139-
builder.bbs = append(builder.bbs, &bb)
139+
builder.bbs = append(builder.bbs, bb)
140140

141141
return builder
142142
}
@@ -146,7 +146,7 @@ func (builder *ConditionBuilder) null(op string, k string) *ConditionBuilder {
146146
op: op,
147147
key: k,
148148
}
149-
builder.bbs = append(builder.bbs, &bb)
149+
builder.bbs = append(builder.bbs, bb)
150150
return builder
151151
}
152152

@@ -160,7 +160,7 @@ func (builder *ConditionBuilder) orAndSub(orAnd string, sub *ConditionBuilder) *
160160
key: orAnd,
161161
subs: sub.bbs,
162162
}
163-
builder.bbs = append(builder.bbs, &bb)
163+
builder.bbs = append(builder.bbs, bb)
164164
return builder
165165
}
166166

@@ -169,14 +169,14 @@ func (builder *ConditionBuilder) orAnd(orAnd string) *ConditionBuilder {
169169
if length == 0 {
170170
return builder
171171
}
172-
pre := *(builder.bbs)[length-1]
172+
pre := builder.bbs[length-1]
173173
if pre.op == OR {
174174
return builder
175175
}
176176
bb := Bb{
177177
op: orAnd,
178178
}
179-
builder.bbs = append(builder.bbs, &bb)
179+
builder.bbs = append(builder.bbs, bb)
180180
return builder
181181
}
182182

source_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type SourceBuilder struct {
2121
alia string
2222
join *Join
2323
sub *BuilderX
24-
bbs []*Bb
24+
bbs []Bb
2525
}
2626

2727
func (sb *SourceBuilder) Source(po Po) *SourceBuilder {

to_sql.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424

2525
type Built struct {
2626
ResultKeys []string
27-
ConditionX []*Bb
27+
ConditionX []Bb
2828
Sorts []*Sort
29-
Havings []*Bb
29+
Havings []Bb
3030
GroupBys []string
3131

3232
Sbs []*SourceBuilder
@@ -98,7 +98,7 @@ func (built *Built) toSourceScriptOfCount(bpCount *strings.Builder) {
9898
built.toSourceScript(bpCount)
9999
}
100100

101-
func (built *Built) toConditionScriptOfCount(bbs []*Bb, bpCount *strings.Builder) {
101+
func (built *Built) toConditionScriptOfCount(bbs []Bb, bpCount *strings.Builder) {
102102
built.toConditionScript(bbs, bpCount, nil, nil)
103103
}
104104

@@ -116,7 +116,7 @@ func (built *Built) toSourceScript(bp *strings.Builder) {
116116
}
117117
}
118118

119-
func (built *Built) toBb(bb *Bb, bp *strings.Builder, vs *[]interface{}) {
119+
func (built *Built) toBb(bb Bb, bp *strings.Builder, vs *[]interface{}) {
120120
op := bb.op
121121
switch op {
122122
case X:
@@ -164,7 +164,7 @@ func (built *Built) toBb(bb *Bb, bp *strings.Builder, vs *[]interface{}) {
164164
}
165165
}
166166

167-
func (built *Built) toConditionScript(bbs []*Bb, bp *strings.Builder, vs *[]interface{}, filterLast func() *Bb) {
167+
func (built *Built) toConditionScript(bbs []Bb, bp *strings.Builder, vs *[]interface{}, filterLast func() *Bb) {
168168

169169
length := len(bbs)
170170
if length == 0 {
@@ -173,7 +173,7 @@ func (built *Built) toConditionScript(bbs []*Bb, bp *strings.Builder, vs *[]inte
173173

174174
if filterLast != nil {
175175
if bb := filterLast(); bb != nil {
176-
built.toBb(bb, bp, vs)
176+
built.toBb(*bb, bp, vs)
177177
if length > 0 {
178178
bp.WriteString(AND_SCRIPT)
179179
}
@@ -223,7 +223,7 @@ func (built *Built) toGroupBySql(bys []string, bp *strings.Builder) {
223223
}
224224
}
225225

226-
func (built *Built) toHavingSql(bys []*Bb, bp *strings.Builder) {
226+
func (built *Built) toHavingSql(bys []Bb, bp *strings.Builder) {
227227
if bys == nil || len(bys) == 0 {
228228
return
229229
}
@@ -266,11 +266,11 @@ func (built *Built) toPageSql(condition *PageCondition, bp *strings.Builder) {
266266
}
267267
}
268268

269-
func (built *Built) isOr(bb *Bb) bool {
269+
func (built *Built) isOr(bb Bb) bool {
270270
return bb.op == OR
271271
}
272272

273-
func (built *Built) isOR(bb *Bb) bool {
273+
func (built *Built) isOR(bb Bb) bool {
274274
return bb.op == OR && bb.key == ""
275275
}
276276

0 commit comments

Comments
 (0)