Avoid duplicate checks in StringViewTemplate<>::Substr().

Incur the complexity of UNSAFE_BUFFERS() in order to bypass the same
checks that were just made being performed via span<>::subspan(). This
should be optimized out on official builds, but debug builds are still
slower.

Change-Id: I2bac2928f28b35dd71e569ce66f991b67918cdd4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117292
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index feb4fcd..b0e3864 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -14,6 +14,7 @@
 #include <optional>
 #include <type_traits>
 
+#include "core/fxcrt/compiler_specific.h"
 #include "core/fxcrt/fx_memcpy_wrappers.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/span.h"
@@ -222,7 +223,8 @@
     if (!IsValidIndex(first + count - 1))
       return StringViewTemplate();
 
-    return StringViewTemplate(m_Span.subspan(first, count));
+    // SAFETY: performance-sensitive, checks above equivalent to subspan()'s.
+    return UNSAFE_BUFFERS(StringViewTemplate(m_Span.data() + first, count));
   }
 
   StringViewTemplate First(size_t count) const {