From 77f87009a34c745255bd84d8f2647040d831a2b3 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 6 Dec 2019 05:36:40 -0800 Subject: Export of internal Abseil changes -- d8ddeda8e52132b908fae89b25f117a055d78c04 by Abseil Team : Improve performance of ByteStringFromAscii by changing kHexValue to have -1 in invalid value slots. This way a single load can do both the validation and conversion. PiperOrigin-RevId: 284167344 -- 5037e97e2eaaac8ced9a5290949deda4b43b9ceb by Mark Barolak : Change the underlying symbol name of Cord to absl::Cord. PiperOrigin-RevId: 284005429 -- 4ef66c72aedf135f2b4fd0ba7a73de6642decfff by Abseil Team : Eliminate an unnecessary load when futex is contended in Waiter::Wait() The first argument to compare_exchange_weak() is a reference and will be updated upon failure. There is no need to do an additional load on the same variable. PiperOrigin-RevId: 284002752 GitOrigin-RevId: d8ddeda8e52132b908fae89b25f117a055d78c04 Change-Id: Idac68a1901eb8c30050adc3860765b1a6fa085c7 --- absl/strings/escaping.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'absl/strings/escaping.cc') diff --git a/absl/strings/escaping.cc b/absl/strings/escaping.cc index 88390fbf..18b746e3 100644 --- a/absl/strings/escaping.cc +++ b/absl/strings/escaping.cc @@ -961,7 +961,7 @@ bool Base64UnescapeInternal(const char* src, size_t slen, String* dest, } /* clang-format off */ -constexpr char kHexValue[256] = { +constexpr char kHexValueLenient[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -977,8 +977,9 @@ constexpr char kHexValue[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + /* clang-format on */ // This is a templated function so that T can be either a char* @@ -987,8 +988,8 @@ constexpr char kHexValue[256] = { template void HexStringToBytesInternal(const char* from, T to, ptrdiff_t num) { for (int i = 0; i < num; i++) { - to[i] = (kHexValue[from[i * 2] & 0xFF] << 4) + - (kHexValue[from[i * 2 + 1] & 0xFF]); + to[i] = (kHexValueLenient[from[i * 2] & 0xFF] << 4) + + (kHexValueLenient[from[i * 2 + 1] & 0xFF]); } } -- cgit v1.2.3