Replace fxcrt::span_equals() with pdfium::span::operator==

Since pdfium::span has an operator== now, use that in place of
span_equals().

Change-Id: I04c9884db91021e021147573e8b9728ec545b446
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/131292
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp b/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp
index 1dd46d1..7cf4ff4 100644
--- a/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp
+++ b/core/fpdfapi/font/cpdf_cmapparser_unittest.cpp
@@ -5,16 +5,15 @@
 #include "core/fpdfapi/font/cpdf_cmapparser.h"
 
 #include "core/fxcrt/span.h"
-#include "core/fxcrt/span_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace {
 
 // Helps with default construction of the appropriate span rather than
-// writing span() and using span_equal() directly.
+// writing span() and using operator== directly.
 bool uint_ranges_equal(pdfium::span<const uint8_t> a,
                        pdfium::span<const uint8_t> b) {
-  return fxcrt::span_equals(a, b);
+  return a == b;
 }
 
 }  // namespace
diff --git a/core/fxcrt/span_util.h b/core/fxcrt/span_util.h
index efe6c10..acf6e58 100644
--- a/core/fxcrt/span_util.h
+++ b/core/fxcrt/span_util.h
@@ -102,24 +102,6 @@
   return true;
 }
 
-// Bounds-checked byte-for-byte equality of same-sized spans. This is
-// helpful because span does not (yet) have an operator==().
-template <typename T1,
-          typename T2,
-          size_t N1,
-          size_t N2,
-          typename P1,
-          typename P2>
-  requires(sizeof(T1) == sizeof(T2) && std::is_trivially_copyable_v<T1> &&
-           std::is_trivially_copyable_v<T2>)
-bool span_equals(pdfium::span<T1, N1, P1> s1, pdfium::span<T2, N2, P2> s2) {
-  // SAFETY: For both `s1` and `s2`, there are `size_bytes()` valid bytes at
-  // the corresponding `data()`, and the sizes are the same.
-  return s1.size_bytes() == s2.size_bytes() &&
-         UNSAFE_BUFFERS(FXSYS_memcmp(s1.data(), s2.data(), s1.size_bytes())) ==
-             0;
-}
-
 // Returns the first position where `needle` occurs in `haystack`.
 template <typename T, typename U, size_t TS, size_t US>
   requires(sizeof(T) == sizeof(U) && std::is_trivially_copyable_v<T> &&
@@ -133,8 +115,7 @@
   // a full match to occur.
   size_t end_pos = haystack.size() - needle.size();
   for (size_t haystack_pos = 0; haystack_pos <= end_pos; ++haystack_pos) {
-    auto candidate = haystack.subspan(haystack_pos, needle.size());
-    if (fxcrt::span_equals(candidate, needle)) {
+    if (haystack.subspan(haystack_pos, needle.size()) == needle) {
       return haystack_pos;
     }
   }
diff --git a/core/fxcrt/span_util_unittest.cpp b/core/fxcrt/span_util_unittest.cpp
index bdb7ed7..de730c7 100644
--- a/core/fxcrt/span_util_unittest.cpp
+++ b/core/fxcrt/span_util_unittest.cpp
@@ -132,32 +132,6 @@
   EXPECT_EQ(dst[2], 'B');
 }
 
-TEST(SpanEquals, Empty) {
-  std::vector<int> vec = {1, 2};
-  std::vector<int> vec2 = {3, 4};
-  pdfium::span<int> empty;
-  pdfium::span<int> some = pdfium::span(vec);
-  pdfium::span<int> some2 = pdfium::span(vec2);
-  EXPECT_FALSE(fxcrt::span_equals(empty, some));
-  EXPECT_FALSE(fxcrt::span_equals(some, empty));
-  EXPECT_TRUE(fxcrt::span_equals(empty, empty));
-  EXPECT_TRUE(fxcrt::span_equals(empty, some.first(0u)));
-  EXPECT_TRUE(fxcrt::span_equals(some.first(0u), empty));
-  EXPECT_TRUE(fxcrt::span_equals(some2.first(0u), some.first(0u)));
-  EXPECT_TRUE(fxcrt::span_equals(some.first(0u), some2.first(0u)));
-}
-
-TEST(SpanEquals, NonEmpty) {
-  std::vector<int> vec = {1, 2, 3};
-  std::vector<int> vec2 = {1, 2, 4};
-  pdfium::span<int> some = pdfium::span(vec);
-  pdfium::span<int> some2 = pdfium::span(vec2);
-  EXPECT_FALSE(fxcrt::span_equals(some, some2));
-  EXPECT_FALSE(fxcrt::span_equals(some.first(2u), some2));
-  EXPECT_FALSE(fxcrt::span_equals(some, some2.first(2u)));
-  EXPECT_TRUE(fxcrt::span_equals(some.first(2u), some2.first(2u)));
-}
-
 TEST(Span, AssignOverOnePastEnd) {
   std::vector<char> src(2, 'A');
   pdfium::span<char> span = pdfium::span(src);
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 56bc77b..639508e 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -26,7 +26,7 @@
 #include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/fx_memcpy_wrappers.h"
 #include "core/fxcrt/fx_system.h"
-#include "core/fxcrt/span_util.h"
+#include "core/fxcrt/span.h"
 #include "core/fxcrt/stl_util.h"
 #include "core/fxge/cfx_defaultrenderdevice.h"
 #include "core/fxge/fx_font.h"
@@ -4150,8 +4150,7 @@
   EXPECT_TRUE(FPDFPageObjMark_GetParamBlobValue(
       mark, "BlobKey", blob_buffer, sizeof(blob_buffer), &out_buffer_len));
   EXPECT_EQ(kBlobLen, out_buffer_len);
-  EXPECT_TRUE(
-      fxcrt::span_equals(pdfium::span(kBlobData), pdfium::span(blob_buffer)));
+  EXPECT_EQ(pdfium::span(kBlobData), blob_buffer);
 
   // Render and check the bitmap is the expected one.
   {