Skip to content

Commit 77476ae

Browse files
committed
refactor ifs into a more efficient switch
Change-Id: I0459ddbe2a2452e779891a260cf6d644c0acefa5
1 parent 6669bb8 commit 77476ae

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

src/cpucounters.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,14 +2322,34 @@ bool PCM::isCPUModelSupported(const int model_)
23222322

23232323
bool PCM::checkModel()
23242324
{
2325-
if (cpu_model == NEHALEM) cpu_model = NEHALEM_EP;
2326-
if (cpu_model == ATOM_2) cpu_model = ATOM;
2327-
if (cpu_model == HASWELL_ULT || cpu_model == HASWELL_2) cpu_model = HASWELL;
2328-
if (cpu_model == BROADWELL_XEON_E3) cpu_model = BROADWELL;
2329-
if (cpu_model == ICX_D) cpu_model = ICX;
2330-
if (cpu_model == CML_1) cpu_model = CML;
2331-
if (cpu_model == ICL_1) cpu_model = ICL;
2332-
if (cpu_model == TGL_1) cpu_model = TGL;
2325+
switch (cpu_model)
2326+
{
2327+
case NEHALEM:
2328+
cpu_model = NEHALEM_EP;
2329+
break;
2330+
case ATOM_2:
2331+
cpu_model = ATOM;
2332+
break;
2333+
case HASWELL_ULT:
2334+
case HASWELL_2:
2335+
cpu_model = HASWELL;
2336+
break;
2337+
case BROADWELL_XEON_E3:
2338+
cpu_model = BROADWELL;
2339+
break;
2340+
case ICX_D:
2341+
cpu_model = ICX;
2342+
break;
2343+
case CML_1:
2344+
cpu_model = CML;
2345+
break;
2346+
case ICL_1:
2347+
cpu_model = ICL;
2348+
break;
2349+
case TGL_1:
2350+
cpu_model = TGL;
2351+
break;
2352+
}
23332353

23342354
if(!isCPUModelSupported((int)cpu_model))
23352355
{

0 commit comments

Comments
 (0)