File tree Expand file tree Collapse file tree 2 files changed +10
-35
lines changed
Expand file tree Collapse file tree 2 files changed +10
-35
lines changed Original file line number Diff line number Diff line change @@ -27,22 +27,11 @@ def Itin {
2727// CHECK-NEXT: static const unsigned TestTargetProcIdToProcResourceIdxTable[][2] = {
2828// CHECK-NEXT: { 2, 1 }, // TestItinerariesModel
2929// CHECK-NEXT: };
30- // CHECK-NEXT: unsigned Mid;
31- // CHECK-NEXT: unsigned Start = 0;
32- // CHECK-NEXT: unsigned End = 1;
33- // CHECK-NEXT: while (Start < End) {
34- // CHECK-NEXT: Mid = Start + (End - Start) / 2;
35- // CHECK-NEXT: if (ProcID == TestTargetProcIdToProcResourceIdxTable[Mid][0]) {
36- // CHECK-NEXT: break;
37- // CHECK-NEXT: }
38- // CHECK-NEXT: if (ProcID < TestTargetProcIdToProcResourceIdxTable[Mid][0])
39- // CHECK-NEXT: End = Mid;
40- // CHECK-NEXT: else
41- // CHECK-NEXT: Start = Mid + 1;
42- // CHECK-NEXT: }
43- // CHECK-NEXT: if (Start == End)
44- // CHECK-NEXT: return -1; // Didn't find
45- // CHECK-NEXT: return TestTargetProcIdToProcResourceIdxTable[Mid][1];
30+ // CHECK-NEXT: auto It = std::lower_bound(
31+ // CHECK-NEXT: std::begin(TestTargetProcIdToProcResourceIdxTable),
32+ // CHECK-NEXT: std::end(TestTargetProcIdToProcResourceIdxTable), ProcID,
33+ // CHECK-NEXT: [](const unsigned LHS[], unsigned Val) { return LHS[0] < Val; });
34+ // CHECK-NEXT: return (*It)[1];
4635// CHECK-NEXT: }
4736
4837// CHECK: unsigned Index = TestTargetGetResourceIndex(IID->SchedModel.ProcID);
Original file line number Diff line number Diff line change @@ -277,25 +277,11 @@ void DFAPacketizerEmitter::emitForItineraries(
277277 << Model->ModelName << " \n " ;
278278 }
279279 OS << " };\n "
280- << " unsigned Mid;\n "
281- << " unsigned Start = 0;\n "
282- << " unsigned End = " << ProcModels.size () << " ;\n "
283- << " while (Start < End) {\n "
284- << " Mid = Start + (End - Start) / 2;\n "
285- << " if (ProcID == " << TargetName << DFAName
286- << " ProcIdToProcResourceIdxTable[Mid][0]) {\n "
287- << " break;\n "
288- << " }\n "
289- << " if (ProcID < " << TargetName << DFAName
290- << " ProcIdToProcResourceIdxTable[Mid][0])\n "
291- << " End = Mid;\n "
292- << " else\n "
293- << " Start = Mid + 1;\n "
294- << " }\n "
295- << " if (Start == End)\n "
296- << " return -1; // Didn't find\n "
297- << " return " << TargetName << DFAName
298- << " ProcIdToProcResourceIdxTable[Mid][1];\n "
280+ << " auto It = std::lower_bound(\n "
281+ << " std::begin(" << TargetName << DFAName << " ProcIdToProcResourceIdxTable),\n "
282+ << " std::end(" << TargetName << DFAName << " ProcIdToProcResourceIdxTable), ProcID,\n "
283+ << " [](const unsigned LHS[], unsigned Val) { return LHS[0] < Val; });\n "
284+ << " return (*It)[1];\n "
299285 << " }\n\n " ;
300286
301287 // The type of a state in the nondeterministic automaton we're defining.
You can’t perform that action at this time.
0 commit comments