@@ -96,7 +96,13 @@ Two.prototype._nodes_with_list_and_one = function (M, list, other) {
96
96
assert ( other instanceof One ) ;
97
97
assert ( Number . isInteger ( list . length ) && list . length >= 1 && list . length <= 4 ) ;
98
98
// 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
+ ] ;
100
106
case 1 :
101
107
return [ node2 ( M , other . a , list [ 0 ] ) , this . _node ( M ) ] ;
102
108
case 2 :
@@ -107,20 +113,20 @@ Two.prototype._nodes_with_list_and_one = function (M, list, other) {
107
113
node2 ( M , list [ 1 ] , list [ 2 ] ) ,
108
114
this . _node ( M ) ,
109
115
] ;
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
- ] ;
116
116
}
117
117
} ;
118
118
119
119
Two . prototype . _nodes_with_list_and_two = function ( M , list , other ) {
120
120
assert ( other instanceof Two ) ;
121
121
assert ( Number . isInteger ( list . length ) && list . length >= 1 && list . length <= 4 ) ;
122
122
// 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
+ ] ;
124
130
case 1 :
125
131
return [ node3 ( M , other . a , other . b , list [ 0 ] ) , node2 ( M , this . a , this . b ) ] ;
126
132
case 2 :
@@ -131,20 +137,20 @@ Two.prototype._nodes_with_list_and_two = function (M, list, other) {
131
137
node3 ( M , list [ 0 ] , list [ 1 ] , list [ 2 ] ) ,
132
138
node2 ( M , this . a , this . b ) ,
133
139
] ;
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
- ] ;
140
140
}
141
141
} ;
142
142
143
143
Two . prototype . _nodes_with_list_and_three = function ( M , list , other ) {
144
144
assert ( other instanceof Three ) ;
145
145
assert ( Number . isInteger ( list . length ) && list . length >= 1 && list . length <= 4 ) ;
146
146
// 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
+ ] ;
148
154
case 1 :
149
155
return [
150
156
node3 ( M , other . a , other . b , other . c ) ,
@@ -162,20 +168,21 @@ Two.prototype._nodes_with_list_and_three = function (M, list, other) {
162
168
node2 ( M , list [ 0 ] , list [ 1 ] ) ,
163
169
node3 ( M , list [ 2 ] , this . a , this . b ) ,
164
170
] ;
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
- ] ;
171
171
}
172
172
} ;
173
173
174
174
Two . prototype . _nodes_with_list_and_four = function ( M , list , other ) {
175
175
assert ( other instanceof Four ) ;
176
176
assert ( Number . isInteger ( list . length ) && list . length >= 1 && list . length <= 4 ) ;
177
177
// 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
+ ] ;
179
186
case 1 :
180
187
return [
181
188
node2 ( M , other . a , other . b ) ,
@@ -194,13 +201,6 @@ Two.prototype._nodes_with_list_and_four = function (M, list, other) {
194
201
node3 ( M , other . d , list [ 0 ] , list [ 1 ] ) ,
195
202
node3 ( M , list [ 2 ] , this . a , this . b ) ,
196
203
] ;
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
- ] ;
204
204
}
205
205
} ;
206
206
0 commit comments