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) |
} |