@@ -334,159 +334,6 @@ defmodule Module.Types.DescrTest do
334334
335335      assert  difference ( tuple ( ) ,  open_tuple ( [ term ( ) ,  term ( ) ] ) ) 
336336             |>  equal? ( union ( tuple ( [ term ( ) ] ) ,  tuple ( [ ] ) ) ) 
337- 
338-       # Large difference with no duplicates 
339-       descr1  =  % { 
340-         dynamic:  % { 
341-           atom:  { :union ,  % { reset:  [ ] ,  ignored:  [ ] } } , 
342-           tuple:  [ 
343-             { :closed ,  [ % { atom:  { :union ,  % { font_style:  [ ] } } } ,  % { atom:  { :union ,  % { italic:  [ ] } } } ] , 
344-              [ ] } 
345-           ] 
346-         } 
347-       } 
348- 
349-       descr2  =  % { 
350-         dynamic:  % { 
351-           atom:  { :union ,  % { reset:  [ ] ,  ignored:  [ ] } } , 
352-           tuple:  [ 
353-             { :closed ,  [ % { atom:  { :union ,  % { font_weight:  [ ] } } } ,  % { atom:  { :union ,  % { bold:  [ ] } } } ] , 
354-              [ ] } , 
355-             { :closed ,  [ % { atom:  { :union ,  % { font_style:  [ ] } } } ,  % { atom:  { :union ,  % { italic:  [ ] } } } ] , 
356-              [ ] } , 
357-             { :closed ,  [ % { atom:  { :union ,  % { font_weight:  [ ] } } } ,  % { atom:  { :union ,  % { clear:  [ ] } } } ] , 
358-              [ ] } , 
359-             { :closed , 
360-              [ 
361-                % { atom:  { :union ,  % { text_decoration:  [ ] } } } , 
362-                % { atom:  { :union ,  % { clear_decoration:  [ ] } } } 
363-              ] ,  [ ] } , 
364-             { :closed , 
365-              [ 
366-                % { atom:  { :union ,  % { text_decoration:  [ ] } } } , 
367-                % { atom:  { :union ,  % { remove_decoration:  [ ] } } } 
368-              ] ,  [ ] } , 
369-             { :closed , 
370-              [ 
371-                % { atom:  { :union ,  % { text_decoration:  [ ] } } } , 
372-                % { atom:  { :union ,  % { undo_decoration:  [ ] } } } 
373-              ] ,  [ ] } , 
374-             { :closed , 
375-              [ 
376-                % { atom:  { :union ,  % { text_decoration:  [ ] } } } , 
377-                % { atom:  { :union ,  % { default_decoration:  [ ] } } } 
378-              ] ,  [ ] } , 
379-             { :closed , 
380-              [ 
381-                % { atom:  { :union ,  % { foreground_color:  [ ] } } } , 
382-                % { atom:  { :union ,  % { clear_foreground:  [ ] } } } 
383-              ] ,  [ ] } , 
384-             { :closed , 
385-              [ 
386-                % { atom:  { :union ,  % { foreground_color:  [ ] } } } , 
387-                % { atom:  { :union ,  % { remove_foreground:  [ ] } } } 
388-              ] ,  [ ] } , 
389-             { :closed , 
390-              [ 
391-                % { atom:  { :union ,  % { foreground_color:  [ ] } } } , 
392-                % { atom:  { :union ,  % { undo_foreground:  [ ] } } } 
393-              ] ,  [ ] } , 
394-             { :closed , 
395-              [ 
396-                % { atom:  { :union ,  % { foreground_color:  [ ] } } } , 
397-                % { atom:  { :union ,  % { default_foreground:  [ ] } } } 
398-              ] ,  [ ] } , 
399-             { :closed , 
400-              [ 
401-                % { atom:  { :union ,  % { background_color:  [ ] } } } , 
402-                % { atom:  { :union ,  % { clear_background:  [ ] } } } 
403-              ] ,  [ ] } , 
404-             { :closed , 
405-              [ 
406-                % { atom:  { :union ,  % { background_color:  [ ] } } } , 
407-                % { atom:  { :union ,  % { remove_background:  [ ] } } } 
408-              ] ,  [ ] } , 
409-             { :closed , 
410-              [ 
411-                % { atom:  { :union ,  % { background_color:  [ ] } } } , 
412-                % { atom:  { :union ,  % { undo_background:  [ ] } } } 
413-              ] ,  [ ] } , 
414-             { :closed , 
415-              [ 
416-                % { atom:  { :union ,  % { background_color:  [ ] } } } , 
417-                % { atom:  { :union ,  % { default_background:  [ ] } } } 
418-              ] ,  [ ] } , 
419-             { :closed , 
420-              [ 
421-                % { atom:  { :union ,  % { text_decoration:  [ ] } } } , 
422-                % { atom:  { :union ,  % { overline:  [ ] } } } 
423-              ] ,  [ ] } , 
424-             { :closed , 
425-              [ 
426-                % { atom:  { :union ,  % { text_decoration:  [ ] } } } , 
427-                % { atom:  { :union ,  % { clear_text:  [ ] } } } 
428-              ] ,  [ ] } , 
429-             { :closed , 
430-              [ 
431-                % { atom:  { :union ,  % { text_decoration:  [ ] } } } , 
432-                % { atom:  { :union ,  % { remove_text:  [ ] } } } 
433-              ] ,  [ ] } , 
434-             { :closed , 
435-              [ 
436-                % { atom:  { :union ,  % { text_decoration:  [ ] } } } , 
437-                % { atom:  { :union ,  % { undo_text:  [ ] } } } 
438-              ] ,  [ ] } , 
439-             { :closed , 
440-              [ 
441-                % { atom:  { :union ,  % { text_decoration:  [ ] } } } , 
442-                % { atom:  { :union ,  % { default_text:  [ ] } } } 
443-              ] ,  [ ] } , 
444-             { :closed , 
445-              [ 
446-                % { atom:  { :union ,  % { foreground_color:  [ ] } } } , 
447-                % { atom:  { :union ,  % { clear_fg:  [ ] } } } 
448-              ] ,  [ ] } , 
449-             { :closed , 
450-              [ 
451-                % { atom:  { :union ,  % { foreground_color:  [ ] } } } , 
452-                % { atom:  { :union ,  % { remove_fg:  [ ] } } } 
453-              ] ,  [ ] } , 
454-             { :closed , 
455-              [ 
456-                % { atom:  { :union ,  % { foreground_color:  [ ] } } } , 
457-                % { atom:  { :union ,  % { undo_fg:  [ ] } } } 
458-              ] ,  [ ] } , 
459-             { :closed , 
460-              [ 
461-                % { atom:  { :union ,  % { foreground_color:  [ ] } } } , 
462-                % { atom:  { :union ,  % { default_fg:  [ ] } } } 
463-              ] ,  [ ] } , 
464-             { :closed , 
465-              [ 
466-                % { atom:  { :union ,  % { background_color:  [ ] } } } , 
467-                % { atom:  { :union ,  % { clear_bg:  [ ] } } } 
468-              ] ,  [ ] } , 
469-             { :closed , 
470-              [ 
471-                % { atom:  { :union ,  % { background_color:  [ ] } } } , 
472-                % { atom:  { :union ,  % { remove_bg:  [ ] } } } 
473-              ] ,  [ ] } , 
474-             { :closed , 
475-              [ 
476-                % { atom:  { :union ,  % { background_color:  [ ] } } } , 
477-                % { atom:  { :union ,  % { undo_bg:  [ ] } } } 
478-              ] ,  [ ] } , 
479-             { :closed , 
480-              [ 
481-                % { atom:  { :union ,  % { background_color:  [ ] } } } , 
482-                % { atom:  { :union ,  % { default_bg:  [ ] } } } 
483-              ] ,  [ ] } 
484-           ] 
485-         } 
486-       } 
487- 
488-       assert  subtype? ( descr1 ,  descr2 ) 
489-       refute  subtype? ( descr2 ,  descr1 ) 
490337    end 
491338
492339    test  "map"  do 
@@ -1454,4 +1301,32 @@ defmodule Module.Types.DescrTest do
14541301               "%{__struct__: Another or URI}" 
14551302    end 
14561303  end 
1304+ 
1305+   describe  "performance"  do 
1306+     test  "tuple difference"  do 
1307+       # Large difference with no duplicates 
1308+       descr1  = 
1309+         union ( 
1310+           atom ( [ :ignored ,  :reset ] ) , 
1311+           tuple ( [ atom ( [ :font_style ] ) ,  atom ( [ :italic ] ) ] ) 
1312+         ) 
1313+ 
1314+       descr2  = 
1315+         union ( 
1316+           atom ( [ :ignored ,  :reset ] ) , 
1317+           union ( 
1318+             tuple ( [ atom ( [ :font_style ] ) ,  atom ( [ :italic ] ) ] ) , 
1319+             Enum . reduce ( 
1320+               for  elem1  <-  1 .. 5 ,  elem2  <-  1 .. 5  do 
1321+                 tuple ( [ atom ( [ :"f#{ elem1 }  " ] ) ,  atom ( [ :"s#{ elem2 }  " ] ) ] ) 
1322+               end , 
1323+               & union / 2 
1324+             ) 
1325+           ) 
1326+         ) 
1327+ 
1328+       assert  subtype? ( descr1 ,  descr2 ) 
1329+       refute  subtype? ( descr2 ,  descr1 ) 
1330+     end 
1331+   end 
14571332end 
0 commit comments