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

Side by Side Diff: service/datastore/multiarg.go

Issue 1291813003: Make LazyMultiError constructed via function (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: interface not pointer Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « service/datastore/datastore.go ('k') | service/memcache/memcache.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package datastore 5 package datastore
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "reflect" 9 "reflect"
10 10
11 "github.com/luci/luci-go/common/errors" 11 "github.com/luci/luci-go/common/errors"
12 ) 12 )
13 13
14 type multiArgType struct { 14 type multiArgType struct {
15 valid bool 15 valid bool
16 16
17 getKey func(nk newKeyFunc, slot reflect.Value) (Key, error) 17 getKey func(nk newKeyFunc, slot reflect.Value) (Key, error)
18 getPM func(slot reflect.Value) (PropertyMap, error) 18 getPM func(slot reflect.Value) (PropertyMap, error)
19 setPM func(slot reflect.Value, pm PropertyMap) error 19 setPM func(slot reflect.Value, pm PropertyMap) error
20 setKey func(slot reflect.Value, k Key) 20 setKey func(slot reflect.Value, k Key)
21 newElem func() reflect.Value 21 newElem func() reflect.Value
22 } 22 }
23 23
24 func (mat *multiArgType) GetKeysPMs(nk newKeyFunc, slice reflect.Value) ([]Key, []PropertyMap, error) { 24 func (mat *multiArgType) GetKeysPMs(nk newKeyFunc, slice reflect.Value) ([]Key, []PropertyMap, error) {
25 retKey := make([]Key, slice.Len()) 25 retKey := make([]Key, slice.Len())
26 retPM := make([]PropertyMap, slice.Len()) 26 retPM := make([]PropertyMap, slice.Len())
27 » lme := errors.LazyMultiError{Size: len(retKey)} 27 » lme := errors.NewLazyMultiError(len(retKey))
28 for i := range retKey { 28 for i := range retKey {
29 key, err := mat.getKey(nk, slice.Index(i)) 29 key, err := mat.getKey(nk, slice.Index(i))
30 if !lme.Assign(i, err) { 30 if !lme.Assign(i, err) {
31 retKey[i] = key 31 retKey[i] = key
32 pm, err := mat.getPM(slice.Index(i)) 32 pm, err := mat.getPM(slice.Index(i))
33 if !lme.Assign(i, err) { 33 if !lme.Assign(i, err) {
34 retPM[i] = pm 34 retPM[i] = pm
35 } 35 }
36 } 36 }
37 } 37 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if pls, ok := o.(*structPLS); ok { 266 if pls, ok := o.(*structPLS); ok {
267 return pls, pls.o.Type().Name() 267 return pls, pls.o.Type().Name()
268 } 268 }
269 if pls, ok := o.(PropertyLoadSaver); ok { 269 if pls, ok := o.(PropertyLoadSaver); ok {
270 return pls, "" 270 return pls, ""
271 } 271 }
272 pls := GetPLS(o) 272 pls := GetPLS(o)
273 name := pls.(*structPLS).o.Type().Name() 273 name := pls.(*structPLS).o.Type().Name()
274 return pls, name 274 return pls, name
275 } 275 }
OLDNEW
« no previous file with comments | « service/datastore/datastore.go ('k') | service/memcache/memcache.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698