IR: Avoid duplication of SwitchInst::findCaseValue(), NFC Change the non-const version of findCaseValue() to forward to the const version.
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index 0ef7888..45984d2 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h
@@ -3515,12 +3515,9 @@ /// default case iterator to indicate that it is handled by the default /// handler. CaseIt findCaseValue(const ConstantInt *C) { - CaseIt I = llvm::find_if( - cases(), [C](CaseHandle &Case) { return Case.getCaseValue() == C; }); - if (I != case_end()) - return I; - - return case_default(); + return CaseIt( + this, + const_cast<const SwitchInst *>(this)->findCaseValue(C)->getCaseIndex()); } ConstCaseIt findCaseValue(const ConstantInt *C) const { ConstCaseIt I = llvm::find_if(cases(), [C](ConstCaseHandle &Case) {