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

Unified Diff: go/src/infra/gae/libs/gae/helper/datastore.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
« no previous file with comments | « go/src/infra/gae/libs/gae/gae.infra_testing ('k') | go/src/infra/gae/libs/gae/helper/datastore_impl.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/gae/helper/datastore.go
diff --git a/go/src/infra/gae/libs/gae/helper/datastore.go b/go/src/infra/gae/libs/gae/helper/datastore.go
index 32622b4c3910dd66d98d96e2d740092e27deef26..425063f5a379fec4b6409abf846dce9fdabfbf33 100644
--- a/go/src/infra/gae/libs/gae/helper/datastore.go
+++ b/go/src/infra/gae/libs/gae/helper/datastore.go
@@ -7,15 +7,14 @@
package helper
import (
- "fmt"
"reflect"
"infra/gae/libs/gae"
)
-// GetStructPLS resolves o into a gae.DSStructPLS. o must be a pointer to a
+// GetPLS resolves o into a gae.DSStructPLS. o must be a pointer to a
// struct of some sort.
-func GetStructPLS(o interface{}) gae.DSStructPLS {
+func GetPLS(o interface{}) gae.DSPropertyLoadSaver {
v := reflect.ValueOf(o)
if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {
return &structPLS{c: &structCodec{problem: gae.ErrDSInvalidEntityType}}
@@ -34,44 +33,3 @@ func GetStructPLS(o interface{}) gae.DSStructPLS {
defer structCodecsMutex.Unlock()
return &structPLS{v, getStructCodecLocked(t)}
}
-
-// GetPLS resolves o into a gae.DSPropertyLoadSaver. If o implements the
-// gae.DSPropertyLoadSaver interface already, it's returned unchanged. Otherwise
-// this calls GetStructPLS and returns the result.
-func GetPLS(o interface{}) (gae.DSPropertyLoadSaver, error) {
- if pls, ok := o.(gae.DSPropertyLoadSaver); ok {
- return pls, nil
- }
- pls := GetStructPLS(o)
- if err := pls.Problem(); err != nil {
- return nil, err
- }
- return pls, nil
-}
-
-// MultiGetPLS resolves os to a []gae.DSPropertyLoadSaver. os must be a slice of
-// something. If os is already a []gae.DSPropertyLoadSaver, it's returned
-// unchanged. Otherwise this calls GetPLS on each item, and composes the
-// resulting slice that way.
-func MultiGetPLS(os interface{}) ([]gae.DSPropertyLoadSaver, error) {
- if plss, ok := os.([]gae.DSPropertyLoadSaver); ok {
- return plss, nil
- }
-
- v := reflect.ValueOf(os)
- if v.Kind() != reflect.Slice {
- return nil, fmt.Errorf("gae/helper: bad type in MultiObjToPLS: %T", os)
- }
-
- // TODO(riannucci): define a higher-level type DSMultiPropertyLoadSaver
- // to avoid this slice?
- ret := make([]gae.DSPropertyLoadSaver, v.Len())
- for i := 0; i < v.Len(); i++ {
- pls, err := GetPLS(v.Index(i).Interface())
- if err != nil {
- return nil, err
- }
- ret[i] = pls
- }
- return ret, nil
-}
« no previous file with comments | « go/src/infra/gae/libs/gae/gae.infra_testing ('k') | go/src/infra/gae/libs/gae/helper/datastore_impl.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698