@@ -57,7 +57,7 @@ fn sort_identity(mut values: Vec<Val>) -> Result<Vec<Val>> {
57
57
Val :: Str ( s) => s. clone ( ) ,
58
58
_ => unreachable ! ( ) ,
59
59
} ) ,
60
- SortKeyType :: Unknown => unreachable ! ( ) ,
60
+ SortKeyType :: Unknown => unreachable ! ( "list is not empty, as checked in sort" ) ,
61
61
} ;
62
62
Ok ( values)
63
63
}
@@ -81,7 +81,7 @@ fn sort_keyf(values: ArrValue, keyf: FuncVal) -> Result<Vec<Thunk<Val>>> {
81
81
Val :: Str ( s) => s. clone ( ) ,
82
82
_ => unreachable ! ( ) ,
83
83
} ) ,
84
- SortKeyType :: Unknown => unreachable ! ( ) ,
84
+ SortKeyType :: Unknown => unreachable ! ( "list is not empty, as checked in sort" ) ,
85
85
} ;
86
86
Ok ( vk. into_iter ( ) . map ( |v| v. 0 ) . collect ( ) )
87
87
}
@@ -103,13 +103,7 @@ pub fn sort(values: ArrValue, key_getter: FuncVal) -> Result<ArrValue> {
103
103
#[ builtin]
104
104
#[ allow( non_snake_case) ]
105
105
pub fn builtin_sort ( arr : ArrValue , keyF : Option < FuncVal > ) -> Result < ArrValue > {
106
- if arr. len ( ) <= 1 {
107
- return Ok ( arr) ;
108
- }
109
- super :: sort:: sort (
110
- arr,
111
- keyF. unwrap_or_else ( FuncVal :: identity) ,
112
- )
106
+ super :: sort:: sort ( arr, keyF. unwrap_or_else ( FuncVal :: identity) )
113
107
}
114
108
115
109
fn uniq_identity ( arr : Vec < Val > ) -> Result < Vec < Val > > {
@@ -160,6 +154,9 @@ pub fn builtin_uniq(arr: ArrValue, keyF: Option<FuncVal>) -> Result<ArrValue> {
160
154
#[ builtin]
161
155
#[ allow( non_snake_case) ]
162
156
pub fn builtin_set ( arr : ArrValue , keyF : Option < FuncVal > ) -> Result < ArrValue > {
157
+ if arr. len ( ) <= 1 {
158
+ return Ok ( arr) ;
159
+ }
163
160
let keyF = keyF. unwrap_or ( FuncVal :: identity ( ) ) ;
164
161
if keyF. is_identity ( ) {
165
162
let arr = arr. iter ( ) . collect :: < Result < Vec < Val > > > ( ) ?;
0 commit comments