Downgrade raw_span<> to span<> in StringViewTemplate. Trade some small amount of temporal safety for performance gains, say, when making repeated Substr() calls in a loop. Change-Id: I637cd8c5f5eb13ecd272369d8988edb851293915 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117211 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Thomas Sepez <tsepez@google.com> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h index 0730ae7..feb4fcd 100644 --- a/core/fxcrt/string_view_template.h +++ b/core/fxcrt/string_view_template.h
@@ -16,7 +16,6 @@ #include "core/fxcrt/fx_memcpy_wrappers.h" #include "core/fxcrt/fx_system.h" -#include "core/fxcrt/raw_span.h" #include "core/fxcrt/span.h" namespace fxcrt { @@ -267,7 +266,10 @@ } protected: - pdfium::raw_span<const UnsignedType> m_Span; + // This is not a raw_span<> because StringViewTemplates must be passed by + // value without introducing BackupRefPtr churn. Also, repeated re-assignment + // of substrings of a StringViewTemplate to itself must avoid the same issue. + pdfium::span<const UnsignedType> m_Span; private: void* operator new(size_t) throw() { return nullptr; }