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

Unified Diff: service/datastore/pls.go

Issue 1259593005: Add 'user friendly' datastore API. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: 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: service/datastore/pls.go
diff --git a/service/rawdatastore/datastore.go b/service/datastore/pls.go
similarity index 74%
rename from service/rawdatastore/datastore.go
rename to service/datastore/pls.go
index 6d7acb0a20f9c4736f35a2b21ca01de3d95281ea..96accb8e444119636a930e7c65c4b033f6d86cac 100644
--- a/service/rawdatastore/datastore.go
+++ b/service/datastore/pls.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package rawdatastore
+package datastore
import (
"reflect"
@@ -16,16 +16,19 @@ func GetPLS(o interface{}) PropertyLoadSaver {
return &structPLS{c: &structCodec{problem: ErrInvalidEntityType}}
}
v = v.Elem()
- t := v.Type()
+ c := getCodec(v.Type())
+ return &structPLS{v, c}
+}
+func getCodec(structType reflect.Type) *structCodec {
structCodecsMutex.RLock()
- if c, ok := structCodecs[t]; ok {
- structCodecsMutex.RUnlock()
- return &structPLS{v, c}
- }
+ c, ok := structCodecs[structType]
structCodecsMutex.RUnlock()
+ if ok {
+ return c
+ }
structCodecsMutex.Lock()
defer structCodecsMutex.Unlock()
- return &structPLS{v, getStructCodecLocked(t)}
+ return getStructCodecLocked(structType)
}

Powered by Google App Engine
This is Rietveld 408576698