@@ -83,35 +83,35 @@ defmodule Msgpax.Unpacker do
8383
8484 import Macro , only: [ pipe: 3 ]
8585
86+ defp unpack ( << buffer :: bits >> , result , options , [ kind , index , size | outer ] , count , count ) do
87+ unpack ( buffer , build_collection ( result , count , kind ) , options , outer , index + 1 , size )
88+ end
89+
8690 for { format , { :value , value } } <- formats do
87- defp unpack ( << unquote_splicing ( format ) , rest :: bits >> , result , options , outer , index , count ) when index < count do
91+ defp unpack ( << unquote_splicing ( format ) , rest :: bits >> , result , options , outer , index , count ) do
8892 unpack ( rest , [ unquote ( value ) | result ] , options , outer , index + 1 , count )
8993 end
9094 end
9195
9296 for { format , { :call , call } } <- formats do
9397 options = Macro . var ( :options , nil )
94- defp unpack ( << unquote_splicing ( format ) , rest :: bits >> , result , options , outer , index , count ) when index < count do
98+ defp unpack ( << unquote_splicing ( format ) , rest :: bits >> , result , options , outer , index , count ) do
9599 unpack ( rest , [ unquote ( pipe ( options , call , 0 ) ) | result ] , options , outer , index + 1 , count )
96100 end
97101 end
98102
99103 for { format , { :collection , :list = kind } } <- formats do
100- defp unpack ( << unquote_splicing ( format ) , rest :: bits >> , result , options , [ kind | outer ] , index , count ) when index < count do
101- unpack ( rest , result , options , [ unquote ( kind ) , { kind , index , count } | outer ] , 0 , unquote ( quote ( do: len ) ) )
104+ defp unpack ( << unquote_splicing ( format ) , rest :: bits >> , result , options , outer , index , count ) do
105+ unpack ( rest , result , options , [ unquote ( kind ) , index , count | outer ] , 0 , unquote ( quote ( do: len ) ) )
102106 end
103107 end
104108
105109 for { format , { :collection , :map = kind } } <- formats do
106- defp unpack ( << unquote_splicing ( format ) , rest :: bits >> , result , options , [ kind | outer ] , index , count ) when index < count do
107- unpack ( rest , result , options , [ unquote ( kind ) , { kind , index , count } | outer ] , 0 , unquote ( quote ( do: len ) ) * 2 )
110+ defp unpack ( << unquote_splicing ( format ) , rest :: bits >> , result , options , outer , index , count ) do
111+ unpack ( rest , result , options , [ unquote ( kind ) , index , count | outer ] , 0 , unquote ( quote ( do: len ) ) * 2 )
108112 end
109113 end
110114
111- defp unpack ( << buffer :: bits >> , result , options , [ kind , { next , index , size } | outer ] , count , count ) do
112- unpack ( buffer , build_collection ( result , count , kind ) , options , [ next | outer ] , index + 1 , size )
113- end
114-
115115 defp unpack ( << byte , _ :: bits >> , [ ] , _options , _outer , _index , _count ) do
116116 throw { :bad_format , byte }
117117 end
0 commit comments