Skip to content

Commit c6cff39

Browse files
committed
Simplify switch/case and add breaks as necessary
1 parent 42883b7 commit c6cff39

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

src/minisketch.cpp

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,40 +102,56 @@ Sketch* Construct(int bits, int impl)
102102
default:
103103
return nullptr;
104104
}
105+
break;
105106
#ifdef HAVE_CLMUL
106107
case FieldImpl::CLMUL:
107-
case FieldImpl::CLMUL_TRI: {
108108
if (EnableClmul()) {
109109
switch ((bits + 7) / 8) {
110110
case 1:
111-
if (FieldImpl(impl) == FieldImpl::CLMUL) return ConstructClMul1Byte(bits, impl);
112-
if (FieldImpl(impl) == FieldImpl::CLMUL_TRI) return ConstructClMulTri1Byte(bits, impl);
111+
return ConstructClMul1Byte(bits, impl);
113112
case 2:
114-
if (FieldImpl(impl) == FieldImpl::CLMUL) return ConstructClMul2Bytes(bits, impl);
115-
if (FieldImpl(impl) == FieldImpl::CLMUL_TRI) return ConstructClMulTri2Bytes(bits, impl);
113+
return ConstructClMul2Bytes(bits, impl);
116114
case 3:
117-
if (FieldImpl(impl) == FieldImpl::CLMUL) return ConstructClMul3Bytes(bits, impl);
118-
if (FieldImpl(impl) == FieldImpl::CLMUL_TRI) return ConstructClMulTri3Bytes(bits, impl);
115+
return ConstructClMul3Bytes(bits, impl);
119116
case 4:
120-
if (FieldImpl(impl) == FieldImpl::CLMUL) return ConstructClMul4Bytes(bits, impl);
121-
if (FieldImpl(impl) == FieldImpl::CLMUL_TRI) return ConstructClMulTri4Bytes(bits, impl);
117+
return ConstructClMul4Bytes(bits, impl);
122118
case 5:
123-
if (FieldImpl(impl) == FieldImpl::CLMUL) return ConstructClMul5Bytes(bits, impl);
124-
if (FieldImpl(impl) == FieldImpl::CLMUL_TRI) return ConstructClMulTri5Bytes(bits, impl);
119+
return ConstructClMul5Bytes(bits, impl);
125120
case 6:
126-
if (FieldImpl(impl) == FieldImpl::CLMUL) return ConstructClMul6Bytes(bits, impl);
127-
if (FieldImpl(impl) == FieldImpl::CLMUL_TRI) return ConstructClMulTri6Bytes(bits, impl);
121+
return ConstructClMul6Bytes(bits, impl);
128122
case 7:
129-
if (FieldImpl(impl) == FieldImpl::CLMUL) return ConstructClMul7Bytes(bits, impl);
130-
if (FieldImpl(impl) == FieldImpl::CLMUL_TRI) return ConstructClMulTri7Bytes(bits, impl);
123+
return ConstructClMul7Bytes(bits, impl);
131124
case 8:
132-
if (FieldImpl(impl) == FieldImpl::CLMUL) return ConstructClMul8Bytes(bits, impl);
133-
if (FieldImpl(impl) == FieldImpl::CLMUL_TRI) return ConstructClMulTri8Bytes(bits, impl);
125+
return ConstructClMul8Bytes(bits, impl);
134126
default:
135127
return nullptr;
136128
}
137129
}
138-
}
130+
break;
131+
case FieldImpl::CLMUL_TRI:
132+
if (EnableClmul()) {
133+
switch ((bits + 7) / 8) {
134+
case 1:
135+
return ConstructClMulTri1Byte(bits, impl);
136+
case 2:
137+
return ConstructClMulTri2Bytes(bits, impl);
138+
case 3:
139+
return ConstructClMulTri3Bytes(bits, impl);
140+
case 4:
141+
return ConstructClMulTri4Bytes(bits, impl);
142+
case 5:
143+
return ConstructClMulTri5Bytes(bits, impl);
144+
case 6:
145+
return ConstructClMulTri6Bytes(bits, impl);
146+
case 7:
147+
return ConstructClMulTri7Bytes(bits, impl);
148+
case 8:
149+
return ConstructClMulTri8Bytes(bits, impl);
150+
default:
151+
return nullptr;
152+
}
153+
}
154+
break;
139155
#endif
140156
}
141157
return nullptr;

0 commit comments

Comments
 (0)