Skip to content

Commit

Permalink
Merge pull request #11 from GokselKUCUKSAHIN/feature/performance
Browse files Browse the repository at this point in the history
feature: change for range over slice to for-i
  • Loading branch information
GokselKUCUKSAHIN committed Jun 4, 2024
2 parents 17c09f7 + 3fbf8c8 commit 728b060
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion benchmarks/aggs_example_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package benchmarks
package benchmarks_test

import (
"encoding/json"
Expand Down
27 changes: 13 additions & 14 deletions es/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ func correctType(b any) (any, bool) {
return Object{"bool": b}, true
case rangeType:
return Object{"range": b}, true
default:
return b, true
}
return b, true
}

func NewQuery(c any) Object {
Expand Down Expand Up @@ -106,8 +105,8 @@ func (b boolType) Filter(items ...any) boolType {
if !exists {
filter = filterType{}
}
for _, item := range items {
if field, ok := correctType(item); ok {
for i := 0; i < len(items); i++ {
if field, ok := correctType(items[i]); ok {
filter = append(filter.(filterType), field)
}
}
Expand All @@ -120,8 +119,8 @@ func (b boolType) Must(items ...any) boolType {
if !exists {
must = mustType{}
}
for _, item := range items {
if field, ok := correctType(item); ok {
for i := 0; i < len(items); i++ {
if field, ok := correctType(items[i]); ok {
must = append(must.(mustType), field)
}
}
Expand All @@ -134,8 +133,8 @@ func (b boolType) MustNot(items ...any) boolType {
if !exists {
mustNot = mustNotType{}
}
for _, item := range items {
if field, ok := correctType(item); ok {
for i := 0; i < len(items); i++ {
if field, ok := correctType(items[i]); ok {
mustNot = append(mustNot.(mustNotType), field)
}
}
Expand All @@ -148,8 +147,8 @@ func (b boolType) Should(items ...any) boolType {
if !exists {
should = shouldType{}
}
for _, item := range items {
if field, ok := correctType(item); ok {
for i := 0; i < len(items); i++ {
if field, ok := correctType(items[i]); ok {
should = append(should.(shouldType), field)
}
}
Expand Down Expand Up @@ -216,8 +215,8 @@ func (s sourceType) Includes(fields ...string) sourceType {
if !exists {
includes = includesType{}
}
for _, field := range fields {
includes = append(includes.(includesType), field)
for i := 0; i < len(fields); i++ {
includes = append(includes.(includesType), fields[i])
}
s["includes"] = includes
return s
Expand All @@ -228,8 +227,8 @@ func (s sourceType) Excludes(fields ...string) sourceType {
if !exists {
excludes = excludesType{}
}
for _, field := range fields {
excludes = append(excludes.(excludesType), field)
for i := 0; i < len(fields); i++ {
excludes = append(excludes.(excludesType), fields[i])
}
s["excludes"] = excludes
return s
Expand Down

0 comments on commit 728b060

Please sign in to comment.