Pre-allocate where and wherein arrays.

This commit is contained in:
Alex Roitman 2020-04-09 09:30:38 -07:00
parent d5132a9eae
commit f3cc365d24

View File

@ -118,14 +118,20 @@ func (s *Server) newScanWriter(
// This fills index value in wheres/whereins // This fills index value in wheres/whereins
// so we don't have to map string field names for each tested object // so we don't have to map string field names for each tested object
var ok bool var ok bool
for _, where := range wheres { if len(wheres) > 0 {
if where.index, ok = sw.fmap[where.field]; ok { sw.wheres = make([]whereT, 0, len(wheres))
sw.wheres = append(sw.wheres, where) for _, where := range wheres {
if where.index, ok = sw.fmap[where.field]; ok {
sw.wheres = append(sw.wheres, where)
}
} }
} }
for _, wherein := range whereins { if len(whereins) > 0 {
if wherein.index, ok = sw.fmap[wherein.field]; ok { sw.whereins = make([]whereinT, 0, len(whereins))
sw.whereins = append(sw.whereins, wherein) for _, wherein := range whereins {
if wherein.index, ok = sw.fmap[wherein.field]; ok {
sw.whereins = append(sw.whereins, wherein)
}
} }
} }
} }