File tree 1 file changed +5
-12
lines changed 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -21,26 +21,19 @@ func (repos RepositoryList) loadAttributes(e Engine) error {
21
21
}
22
22
23
23
// Load owners.
24
- set := make (map [int64 ]* User )
24
+ set := make (map [int64 ]struct {} )
25
25
for i := range repos {
26
- set [repos [i ].OwnerID ] = nil
26
+ set [repos [i ].OwnerID ] = struct {}{}
27
27
}
28
- userIDs := make ([]int64 , 0 , len (set ))
29
- for userID := range set {
30
- userIDs = append (userIDs , userID )
31
- }
32
- users := make ([]* User , 0 , len (userIDs ))
28
+ users := make (map [int64 ]* User , len (set ))
33
29
if err := e .
34
30
Where ("id > 0" ).
35
- In ("id" , userIDs ).
31
+ In ("id" , keysInt64 ( set ) ).
36
32
Find (& users ); err != nil {
37
33
return fmt .Errorf ("find users: %v" , err )
38
34
}
39
- for i := range users {
40
- set [users [i ].ID ] = users [i ]
41
- }
42
35
for i := range repos {
43
- repos [i ].Owner = set [repos [i ].OwnerID ]
36
+ repos [i ].Owner = users [repos [i ].OwnerID ]
44
37
}
45
38
return nil
46
39
}
You can’t perform that action at this time.
0 commit comments