@@ -96,7 +96,13 @@ Two.prototype._nodes_with_list_and_one = function (M, list, other) {
9696 assert ( other instanceof One ) ;
9797 assert ( Number . isInteger ( list . length ) && list . length >= 1 && list . length <= 4 ) ;
9898 // eslint-disable-next-line default-case
99- switch ( list . length ) {
99+ switch ( list . length & 0b11 ) {
100+ case 0 :
101+ return [
102+ node2 ( M , other . a , list [ 0 ] ) ,
103+ node3 ( M , list [ 1 ] , list [ 2 ] , list [ 3 ] ) ,
104+ this . _node ( M ) ,
105+ ] ;
100106 case 1 :
101107 return [ node2 ( M , other . a , list [ 0 ] ) , this . _node ( M ) ] ;
102108 case 2 :
@@ -107,20 +113,20 @@ Two.prototype._nodes_with_list_and_one = function (M, list, other) {
107113 node2 ( M , list [ 1 ] , list [ 2 ] ) ,
108114 this . _node ( M ) ,
109115 ] ;
110- case 4 :
111- return [
112- node2 ( M , other . a , list [ 0 ] ) ,
113- node3 ( M , list [ 1 ] , list [ 2 ] , list [ 3 ] ) ,
114- this . _node ( M ) ,
115- ] ;
116116 }
117117} ;
118118
119119Two . prototype . _nodes_with_list_and_two = function ( M , list , other ) {
120120 assert ( other instanceof Two ) ;
121121 assert ( Number . isInteger ( list . length ) && list . length >= 1 && list . length <= 4 ) ;
122122 // eslint-disable-next-line default-case
123- switch ( list . length ) {
123+ switch ( list . length & 0b11 ) {
124+ case 0 :
125+ return [
126+ node3 ( M , other . a , other . b , list [ 0 ] ) ,
127+ node2 ( M , list [ 1 ] , list [ 2 ] ) ,
128+ node3 ( M , list [ 3 ] , this . a , this . b ) ,
129+ ] ;
124130 case 1 :
125131 return [ node3 ( M , other . a , other . b , list [ 0 ] ) , node2 ( M , this . a , this . b ) ] ;
126132 case 2 :
@@ -131,20 +137,20 @@ Two.prototype._nodes_with_list_and_two = function (M, list, other) {
131137 node3 ( M , list [ 0 ] , list [ 1 ] , list [ 2 ] ) ,
132138 node2 ( M , this . a , this . b ) ,
133139 ] ;
134- case 4 :
135- return [
136- node3 ( M , other . a , other . b , list [ 0 ] ) ,
137- node2 ( M , list [ 1 ] , list [ 2 ] ) ,
138- node3 ( M , list [ 3 ] , this . a , this . b ) ,
139- ] ;
140140 }
141141} ;
142142
143143Two . prototype . _nodes_with_list_and_three = function ( M , list , other ) {
144144 assert ( other instanceof Three ) ;
145145 assert ( Number . isInteger ( list . length ) && list . length >= 1 && list . length <= 4 ) ;
146146 // eslint-disable-next-line default-case
147- switch ( list . length ) {
147+ switch ( list . length & 0b11 ) {
148+ case 0 :
149+ return [
150+ node3 ( M , other . a , other . b , other . c ) ,
151+ node3 ( M , list [ 0 ] , list [ 1 ] , list [ 2 ] ) ,
152+ node3 ( M , list [ 3 ] , this . a , this . b ) ,
153+ ] ;
148154 case 1 :
149155 return [
150156 node3 ( M , other . a , other . b , other . c ) ,
@@ -162,20 +168,21 @@ Two.prototype._nodes_with_list_and_three = function (M, list, other) {
162168 node2 ( M , list [ 0 ] , list [ 1 ] ) ,
163169 node3 ( M , list [ 2 ] , this . a , this . b ) ,
164170 ] ;
165- case 4 :
166- return [
167- node3 ( M , other . a , other . b , other . c ) ,
168- node3 ( M , list [ 0 ] , list [ 1 ] , list [ 2 ] ) ,
169- node3 ( M , list [ 3 ] , this . a , this . b ) ,
170- ] ;
171171 }
172172} ;
173173
174174Two . prototype . _nodes_with_list_and_four = function ( M , list , other ) {
175175 assert ( other instanceof Four ) ;
176176 assert ( Number . isInteger ( list . length ) && list . length >= 1 && list . length <= 4 ) ;
177177 // eslint-disable-next-line default-case
178- switch ( list . length ) {
178+ switch ( list . length & 0b11 ) {
179+ case 0 :
180+ return [
181+ node2 ( M , other . a , other . b ) ,
182+ node3 ( M , other . c , other . d , list [ 0 ] ) ,
183+ node3 ( M , list [ 1 ] , list [ 2 ] , list [ 3 ] ) ,
184+ node2 ( M , this . a , this . b ) ,
185+ ] ;
179186 case 1 :
180187 return [
181188 node2 ( M , other . a , other . b ) ,
@@ -194,13 +201,6 @@ Two.prototype._nodes_with_list_and_four = function (M, list, other) {
194201 node3 ( M , other . d , list [ 0 ] , list [ 1 ] ) ,
195202 node3 ( M , list [ 2 ] , this . a , this . b ) ,
196203 ] ;
197- case 4 :
198- return [
199- node2 ( M , other . a , other . b ) ,
200- node3 ( M , other . c , other . d , list [ 0 ] ) ,
201- node3 ( M , list [ 1 ] , list [ 2 ] , list [ 3 ] ) ,
202- node2 ( M , this . a , this . b ) ,
203- ] ;
204204 }
205205} ;
206206
0 commit comments