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

Unified Diff: go/src/infra/gae/libs/gae/prod/datastore_key.go

Issue 1227183003: Change RawDatastore to do less reflection. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@move_dummy
Patch Set: fix No/ShouldIndex Created 5 years, 5 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
Index: go/src/infra/gae/libs/gae/prod/datastore_key.go
diff --git a/go/src/infra/gae/libs/gae/prod/datastore_key.go b/go/src/infra/gae/libs/gae/prod/datastore_key.go
index 2b823114f3c6006d2124ba715420fbea9d1d47fe..13a7766ff4b79486685934cc5a61b2567f408482 100644
--- a/go/src/infra/gae/libs/gae/prod/datastore_key.go
+++ b/go/src/infra/gae/libs/gae/prod/datastore_key.go
@@ -17,12 +17,7 @@ type dsKeyImpl struct {
var _ gae.DSKey = dsKeyImpl{}
-func (k dsKeyImpl) Equal(other gae.DSKey) bool { return k.Key.Equal(dsF2R(other)) }
-func (k dsKeyImpl) Parent() gae.DSKey { return dsR2F(k.Key.Parent()) }
-func (k dsKeyImpl) Root() gae.DSKey { return helper.DSKeyRoot(k) }
-func (k dsKeyImpl) Valid(ns string, allowSpecial bool) bool {
- return helper.DSKeyValid(k, ns, allowSpecial)
-}
+func (k dsKeyImpl) Parent() gae.DSKey { return dsR2F(k.Key.Parent()) }
// dsR2F (DS real-to-fake) converts an SDK Key to a gae.DSKey
func dsR2F(k *datastore.Key) gae.DSKey {
@@ -57,6 +52,10 @@ func dsF2R(k gae.DSKey) *datastore.Key {
// trip through the proto encoding.
rkey, err := datastore.DecodeKey(helper.DSKeyEncode(k))
if err != nil {
+ // should never happen in a good program, but it's not ignorable, and
+ // passing an error back makes this function too cumbersome (and it causes
+ // this `if err != nil { panic(err) }` logic to show up in a bunch of
+ // places. Realistically, everything should hit the early exit clause above.
panic(err)
}
return rkey
« no previous file with comments | « go/src/infra/gae/libs/gae/memory/testing_utils_test.go ('k') | go/src/infra/gae/libs/gae/prod/raw_datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698