Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: service/datastore/query.go

Issue 1409613002: Use the sort.Search api correctly. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | service/datastore/query_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/query.go
diff --git a/service/datastore/query.go b/service/datastore/query.go
index a68bca28686611eac9cead0e1feecf324c656c05..fc30f5f686808fc6f697a000c6be3bdf94e0cf65 100644
--- a/service/datastore/query.go
+++ b/service/datastore/query.go
@@ -270,11 +270,13 @@ func (q *Query) Eq(field string, values ...interface{}) *Query {
return
}
idx := sort.Search(len(s), func(i int) bool {
- return s[i].Equal(&p)
+ // s[i] >= p is the same as:
+ return s[i].Equal(&p) || p.Less(&s[i])
})
- if idx == len(s) {
- s = append(s, p)
- sort.Sort(s)
+ if idx == len(s) || !s[idx].Equal(&p) {
+ s = append(s, Property{})
+ copy(s[idx+1:], s[idx:])
dnj 2015/10/15 02:23:46 nit: WDYT about making eqfilts a binheap?
+ s[idx] = p
}
}
q.eqFilts[field] = s
« no previous file with comments | « no previous file | service/datastore/query_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698