@@ -1867,10 +1867,10 @@ defmodule GenStage do
1867
1867
def init ( { mod , args } ) do
1868
1868
case mod . init ( args ) do
1869
1869
{ :producer , state } ->
1870
- init_producer ( mod , [ ] , state , nil )
1870
+ init_producer ( mod , [ ] , state )
1871
1871
1872
1872
{ :producer , state , opts } when is_list ( opts ) ->
1873
- init_producer ( mod , opts , state , nil )
1873
+ init_producer ( mod , opts , state )
1874
1874
1875
1875
{ :producer , state , opts , additional_info } when is_list ( opts ) ->
1876
1876
init_producer ( mod , opts , state , additional_info )
@@ -1904,7 +1904,7 @@ defmodule GenStage do
1904
1904
end
1905
1905
end
1906
1906
1907
- defp init_producer ( mod , opts , state , additional_info ) do
1907
+ defp init_producer ( mod , opts , state ) do
1908
1908
with { :ok , dispatcher_mod , dispatcher_state , opts } <- init_dispatcher ( opts ) ,
1909
1909
{ :ok , buffer_size , opts } <-
1910
1910
Utils . validate_integer ( opts , :buffer_size , 10000 , 0 , :infinity , true ) ,
@@ -1923,13 +1923,18 @@ defmodule GenStage do
1923
1923
dispatcher_mod: dispatcher_mod ,
1924
1924
dispatcher_state: dispatcher_state
1925
1925
}
1926
-
1927
- if additional_info , do: { :ok , stage , additional_info } , else: { :ok , stage }
1926
+ { :ok , stage }
1928
1927
else
1929
1928
{ :error , message } -> { :stop , { :bad_opts , message } }
1930
1929
end
1931
1930
end
1932
1931
1932
+ defp init_producer ( mod , opts , state , additional_info ) do
1933
+ with { :ok , stage } <- init_producer ( mod , opts , state ) do
1934
+ { :ok , stage , additional_info }
1935
+ end
1936
+ end
1937
+
1933
1938
defp init_dispatcher ( opts ) do
1934
1939
case Keyword . pop ( opts , :dispatcher , GenStage.DemandDispatcher ) do
1935
1940
{ dispatcher , opts } when is_atom ( dispatcher ) ->
0 commit comments