File tree Expand file tree Collapse file tree 1 file changed +1
-25
lines changed
Expand file tree Collapse file tree 1 file changed +1
-25
lines changed Original file line number Diff line number Diff line change @@ -205,37 +205,13 @@ pub fn can_message(address: &Address) -> bool {
205205}
206206
207207/// Get a capability in our store
208- /// NOTE unfortunatly this is O(n), not sure if wit let's us do any better
209208pub fn get_capability ( our : & Address , params : & str ) -> Option < Capability > {
210209 let params = serde_json:: from_str :: < Value > ( params) . unwrap_or_default ( ) ;
211210 crate :: our_capabilities ( )
212211 . iter ( )
213212 . find ( |cap| {
214213 let cap_params = serde_json:: from_str :: < Value > ( & cap. params ) . unwrap_or_default ( ) ;
215- cap. issuer == * our && are_equal_json_values ( & params, & cap_params)
214+ cap. issuer == * our && params == cap_params
216215 } )
217216 . cloned ( )
218217}
219-
220- fn are_equal_json_objects ( obj1 : & Value , obj2 : & Value ) -> bool {
221- match ( obj1. as_object ( ) , obj2. as_object ( ) ) {
222- ( Some ( map1) , Some ( map2) ) => {
223- if map1. len ( ) != map2. len ( ) {
224- return false ;
225- }
226-
227- map1. iter ( ) . all ( |( key, val1) | {
228- map2. get ( key)
229- . map_or ( false , |val2| are_equal_json_values ( val1, val2) )
230- } )
231- }
232- _ => false ,
233- }
234- }
235-
236- fn are_equal_json_values ( val1 : & Value , val2 : & Value ) -> bool {
237- match ( val1, val2) {
238- ( Value :: Object ( _) , Value :: Object ( _) ) => are_equal_json_objects ( val1, val2) ,
239- _ => val1 == val2,
240- }
241- }
You can’t perform that action at this time.
0 commit comments