@@ -46,10 +46,10 @@ impl<'a> Fields1<'a> {
46
46
serde_json_borrow:: Value :: Object ( ans)
47
47
}
48
48
#[ inline( always) ]
49
- fn finalize_inner ( field : & ' a Field1 < ' a > , mut value : Option < serde_json_borrow:: Value < ' a > > , index : Option < usize > ) -> serde_json_borrow:: Value < ' a > {
49
+ fn finalize_inner ( field : & ' a Field1 < ' a > , mut value : Option < & ' a serde_json_borrow:: Value < ' a > > , index : Option < usize > ) -> serde_json_borrow:: Value < ' a > {
50
50
if let Some ( val) = & field. resolved {
51
51
if value. is_none ( ) {
52
- value = Some ( val. clone ( ) ) ;
52
+ value = Some ( val) ;
53
53
}
54
54
}
55
55
if let Some ( val) = value. clone ( ) {
@@ -60,12 +60,12 @@ impl<'a> Fields1<'a> {
60
60
61
61
if field. nested . is_empty ( ) {
62
62
let val = obj. get_key ( field. name ) ;
63
- let value = Self :: finalize_inner ( field, val. cloned ( ) , index) ;
63
+ let value = Self :: finalize_inner ( field, val, index) ;
64
64
ans. insert ( field. name , value) ;
65
65
} else {
66
66
for child in field. nested . iter ( ) {
67
67
let child_name = child. name ;
68
- let val = obj. get_key ( child. name ) . cloned ( ) ;
68
+ let val = obj. get_key ( child. name ) ;
69
69
let val = Self :: finalize_inner ( child, val, index) ;
70
70
ans. insert ( child_name, val) ;
71
71
}
@@ -75,19 +75,19 @@ impl<'a> Fields1<'a> {
75
75
}
76
76
( Some ( arr) , _) => {
77
77
if let Some ( index) = index {
78
- let val = arr. get ( index) . cloned ( ) ;
78
+ let val = arr. get ( index) ;
79
79
let val = Self :: finalize_inner ( field, val, None ) ;
80
80
val
81
81
} else {
82
82
let mut ans = vec ! [ ] ;
83
83
for ( i, val) in arr. iter ( ) . enumerate ( ) {
84
- let val = Self :: finalize_inner ( field, Some ( val. clone ( ) ) , Some ( i) ) ;
84
+ let val = Self :: finalize_inner ( field, Some ( val) , Some ( i) ) ;
85
85
ans. push ( val) ;
86
86
}
87
87
serde_json_borrow:: Value :: Array ( ans)
88
88
}
89
89
}
90
- _ => value. unwrap_or_default ( ) ,
90
+ _ => value. cloned ( ) . unwrap_or_default ( ) ,
91
91
}
92
92
} else {
93
93
serde_json_borrow:: Value :: Null
@@ -162,25 +162,25 @@ impl Fields {
162
162
for mut field in fields {
163
163
let mut parent_val = None ;
164
164
165
- if let Some ( ir) = field. ir . clone ( ) {
165
+ if let Some ( ir) = field. ir . as_ref ( ) {
166
166
if let Some ( val) = field. args . clone ( ) {
167
167
eval_context = eval_context. with_args ( val) ;
168
168
}
169
169
170
170
let val = match & parent {
171
171
Some ( val) => {
172
- match val. clone ( ) . into_serde ( ) {
172
+ match val. serde ( ) {
173
173
serde_json:: Value :: Array ( arr) => {
174
174
let mut ans = vec ! [ ] ;
175
175
for val in arr {
176
- eval_context = eval_context. with_value ( Value :: new ( val) ) ;
176
+ eval_context = eval_context. with_value ( Value :: new ( val. clone ( ) ) ) ;
177
177
let val = ir. eval ( & mut eval_context. clone ( ) ) . await ?;
178
178
ans. push ( val. into_serde ( ) ) ;
179
179
}
180
180
Some ( Value :: new ( serde_json:: Value :: Array ( ans) ) )
181
181
}
182
182
val => {
183
- eval_context = eval_context. with_value ( Value :: new ( val) ) ;
183
+ eval_context = eval_context. with_value ( Value :: new ( val. clone ( ) ) ) ;
184
184
let val = ir. eval ( & mut eval_context. clone ( ) ) . await ?;
185
185
Some ( val)
186
186
}
0 commit comments