diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/crypto/normalize_algorithm.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/modules/crypto/normalize_algorithm.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/chromium/third_party/blink/renderer/modules/crypto/normalize_algorithm.cc b/chromium/third_party/blink/renderer/modules/crypto/normalize_algorithm.cc index d2b2e118d7e..89e26470f6f 100644 --- a/chromium/third_party/blink/renderer/modules/crypto/normalize_algorithm.cc +++ b/chromium/third_party/blink/renderer/modules/crypto/normalize_algorithm.cc @@ -32,6 +32,9 @@ #include <algorithm> #include <memory> + +#include "base/stl_util.h" +#include "base/strings/char_traits.h" #include "third_party/blink/public/platform/web_crypto_algorithm_params.h" #include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/renderer/bindings/core/v8/array_buffer_or_array_buffer_view.h" @@ -86,7 +89,7 @@ const AlgorithmNameMapping kAlgorithmNameMappings[] = { // Reminder to update the table mapping names to IDs whenever adding a new // algorithm ID. static_assert(kWebCryptoAlgorithmIdLast + 1 == - arraysize(kAlgorithmNameMappings), + base::size(kAlgorithmNameMappings), "algorithmNameMappings needs to be updated"); #if DCHECK_IS_ON() @@ -177,7 +180,7 @@ bool LookupAlgorithmIdByName(const String& algorithm_name, WebCryptoAlgorithmId& id) { const AlgorithmNameMapping* begin = kAlgorithmNameMappings; const AlgorithmNameMapping* end = - kAlgorithmNameMappings + arraysize(kAlgorithmNameMappings); + kAlgorithmNameMappings + base::size(kAlgorithmNameMappings); #if DCHECK_IS_ON() DCHECK(VerifyAlgorithmNameMappings(begin, end)); @@ -228,16 +231,18 @@ class ErrorContext { return String(); StringBuilder result; - constexpr const char* separator = ": "; + constexpr const char* const separator = ": "; + constexpr wtf_size_t separator_length = + base::CharTraits<char>::length(separator); - wtf_size_t length = (messages_.size() - 1) * strlen(separator); + wtf_size_t length = (messages_.size() - 1) * separator_length; for (wtf_size_t i = 0; i < messages_.size(); ++i) length += strlen(messages_[i]); result.ReserveCapacity(length); for (wtf_size_t i = 0; i < messages_.size(); ++i) { if (i) - result.Append(separator, strlen(separator)); + result.Append(separator, separator_length); result.Append(messages_[i], static_cast<wtf_size_t>(strlen(messages_[i]))); } @@ -772,7 +777,7 @@ const CurveNameMapping kCurveNameMappings[] = { {"P-521", kWebCryptoNamedCurveP521}}; // Reminder to update curveNameMappings when adding a new curve. -static_assert(kWebCryptoNamedCurveLast + 1 == arraysize(kCurveNameMappings), +static_assert(kWebCryptoNamedCurveLast + 1 == base::size(kCurveNameMappings), "curveNameMappings needs to be updated"); bool ParseNamedCurve(const Dictionary& raw, @@ -786,7 +791,7 @@ bool ParseNamedCurve(const Dictionary& raw, return false; } - for (size_t i = 0; i < arraysize(kCurveNameMappings); ++i) { + for (size_t i = 0; i < base::size(kCurveNameMappings); ++i) { if (kCurveNameMappings[i].name == named_curve_string) { named_curve = kCurveNameMappings[i].value; return true; |