diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index 7f5fa3271ac..e973054daef 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -135,15 +135,9 @@ namespace llvm { /// equals - Check for element-wise equality. bool equals(ArrayRef RHS) const { - if (Length != RHS.Length) + if (Length != RHS.Length || Length == 0) return false; - // Don't use std::equal(), since it asserts in MSVC on nullptr iterators. - for (auto L = begin(), LE = end(), R = RHS.begin(); L != LE; ++L, ++R) - // Match std::equal() in using == (instead of !=) to minimize API - // requirements of ArrayRef'ed types. - if (!(*L == *R)) - return false; - return true; + return std::equal(begin(), end(), RHS.begin()); } /// slice(n) - Chop off the first N elements of the array.