-int ConvertCostTableLookup(const TypeConversionCostTblEntry<TypeTy> *Tbl,
- unsigned len, int ISD, CompareTy Dst,
- CompareTy Src) {
- for (unsigned int i = 0; i < len; ++i)
- if (ISD == Tbl[i].ISD && Src == Tbl[i].Src && Dst == Tbl[i].Dst)
- return i;
+const TypeConversionCostTblEntry<TypeTy> *
+ConvertCostTableLookup(ArrayRef<TypeConversionCostTblEntry<TypeTy>> Tbl,
+ int ISD, CompareTy Dst, CompareTy Src) {
+ auto I = std::find_if(Tbl.begin(), Tbl.end(),
+ [=](const TypeConversionCostTblEntry<TypeTy> &Entry) {
+ return ISD == Entry.ISD && Src == Entry.Src &&
+ Dst == Entry.Dst;
+ });
+ if (I != Tbl.end())
+ return I;