forked from mirror/gorm
optimize value of reflection length (#4152)
This commit is contained in:
parent
a3abb5fedf
commit
221d0a0ec1
|
@ -35,10 +35,12 @@ func (db *DB) CreateInBatches(value interface{}, batchSize int) (tx *DB) {
|
||||||
tx = db.getInstance()
|
tx = db.getInstance()
|
||||||
|
|
||||||
callFc := func(tx *DB) error {
|
callFc := func(tx *DB) error {
|
||||||
for i := 0; i < reflectValue.Len(); i += batchSize {
|
// the reflection length judgment of the optimized value
|
||||||
|
reflectLen := reflectValue.Len()
|
||||||
|
for i := 0; i < reflectLen; i += batchSize {
|
||||||
ends := i + batchSize
|
ends := i + batchSize
|
||||||
if ends > reflectValue.Len() {
|
if ends > reflectLen {
|
||||||
ends = reflectValue.Len()
|
ends = reflectLen
|
||||||
}
|
}
|
||||||
|
|
||||||
subtx := tx.getInstance()
|
subtx := tx.getInstance()
|
||||||
|
|
Loading…
Reference in New Issue