@@ -1897,18 +1897,18 @@ defmodule Module.Types.Descr do
18971897
18981898 defp map_non_negated_fuse ( maps ) do
18991899 Enum . reduce ( maps , [ ] , fn map , acc ->
1900- fuse_with_first_fusible ( map , acc )
1900+ map_fuse_with_first_fusible ( map , acc )
19011901 end )
19021902 end
19031903
1904- defp fuse_with_first_fusible ( map , [ ] ) , do: [ map ]
1904+ defp map_fuse_with_first_fusible ( map , [ ] ) , do: [ map ]
19051905
1906- defp fuse_with_first_fusible ( map , [ candidate | rest ] ) do
1906+ defp map_fuse_with_first_fusible ( map , [ candidate | rest ] ) do
19071907 if fused = maybe_optimize_map_union ( map , candidate ) do
19081908 # we found a fusible candidate, we're done
19091909 [ fused | rest ]
19101910 else
1911- [ candidate | fuse_with_first_fusible ( map , rest ) ]
1911+ [ candidate | map_fuse_with_first_fusible ( map , rest ) ]
19121912 end
19131913 end
19141914
@@ -2286,27 +2286,19 @@ defmodule Module.Types.Descr do
22862286
22872287 defp tuple_non_negated_fuse ( tuples ) do
22882288 Enum . reduce ( tuples , [ ] , fn tuple , acc ->
2289- case Enum . split_while ( acc , & non_fusible_tuples? ( tuple , & 1 ) ) do
2290- { _ , [ ] } ->
2291- [ tuple | acc ]
2292-
2293- { others , [ match | rest ] } ->
2294- fused = tuple_non_negated_fuse_pair ( tuple , match )
2295- others ++ [ fused | rest ]
2296- end
2289+ tuple_fuse_with_first_fusible ( tuple , acc )
22972290 end )
22982291 end
22992292
2300- # Two tuples are fusible if they have no negations and differ in at most one element.
2301- defp non_fusible_tuples? ( { _ , elems1 , [ ] } , { _ , elems2 , [ ] } ) do
2302- Enum . zip ( elems1 , elems2 ) |> Enum . count_until ( fn { a , b } -> a != b end , 2 ) > 1
2303- end
2304-
2305- defp tuple_non_negated_fuse_pair ( { tag , elems1 , [ ] } , { _ , elems2 , [ ] } ) do
2306- fused_elements =
2307- Enum . zip_with ( elems1 , elems2 , fn a , b -> if a == b , do: a , else: union ( a , b ) end )
2293+ defp tuple_fuse_with_first_fusible ( tuple , [ ] ) , do: [ tuple ]
23082294
2309- { tag , fused_elements , [ ] }
2295+ defp tuple_fuse_with_first_fusible ( tuple , [ candidate | rest ] ) do
2296+ if fused = maybe_optimize_tuple_union ( tuple , candidate ) do
2297+ # we found a fusible candidate, we're done
2298+ [ fused | rest ]
2299+ else
2300+ [ candidate | tuple_fuse_with_first_fusible ( tuple , rest ) ]
2301+ end
23102302 end
23112303
23122304 defp tuple_each_to_quoted ( { tag , positive_tuple , negative_tuples } , opts ) do
0 commit comments