summaryrefslogtreecommitdiff
path: root/absl/strings
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-03-04 09:10:07 -0800
committerGravatar Matt Kulukundis <matt.fowles@gmail.com>2021-03-05 09:40:59 -0500
commitab21820d47e4f83875dda008b600514d3520fd35 (patch)
treee32adb788be1e541a2fdfb91b5edf92a84f897e4 /absl/strings
parentb0735979d778a768caee207f01f327535cbd2140 (diff)
Export of internal Abseil changes
-- e2de21d54c02b6419c57c0f4e2a16b608deca260 by Evan Brown <ezb@google.com>: Remove the InsertEnd benchmark. This benchmark has significantly different possible behaviors that can result in misleading metrics. Specifically, we can have a case where we are deallocating the last node in the b-tree in the erase and then allocating a new node in the insert call repeatedly, whereas normally, we end up just inserting/erasing a value from the last node. Also, the name of the benchmark is misleading because it involves an erase and an insert, but the name only mentions the insert. PiperOrigin-RevId: 360930639 -- 51f6bb97b9cbdb809c31b77e93ce080ca3cba9ea by Benjamin Barenblat <bbaren@google.com>: Stop testing with double-double random variables On POWER, long double is often represented as a pair of doubles added together (double-double arithmetic). We’ve already special-cased double-double arithmetic in a number of tests, but compiler bugs [1, 2, 3] have now triggered both false positives and false negatives, which suggests testing with double doubles is unlikely to yield useful signal. Remove the special casing and detect if we’re on a double-double system; if so, just don’t test long doubles. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99048 [2] https://bugs.llvm.org/show_bug.cgi?id=49131 [3] https://bugs.llvm.org/show_bug.cgi?id=49132 PiperOrigin-RevId: 360793161 -- 07fb4d7932c2f5d711c480f759dacb0be60f975e by Abseil Team <absl-team@google.com>: internal change PiperOrigin-RevId: 360712825 GitOrigin-RevId: e2de21d54c02b6419c57c0f4e2a16b608deca260 Change-Id: I98389b5a8789dcc8f35abc00c767e909181665f0
Diffstat (limited to 'absl/strings')
-rw-r--r--absl/strings/BUILD.bazel1
-rw-r--r--absl/strings/CMakeLists.txt1
-rw-r--r--absl/strings/internal/str_format/float_conversion.cc12
3 files changed, 7 insertions, 7 deletions
diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel
index 5efaf896..123b5efb 100644
--- a/absl/strings/BUILD.bazel
+++ b/absl/strings/BUILD.bazel
@@ -709,6 +709,7 @@ cc_library(
"//absl/meta:type_traits",
"//absl/numeric:bits",
"//absl/numeric:int128",
+ "//absl/numeric:representation",
"//absl/types:optional",
"//absl/types:span",
],
diff --git a/absl/strings/CMakeLists.txt b/absl/strings/CMakeLists.txt
index 12f322a9..3b7ae639 100644
--- a/absl/strings/CMakeLists.txt
+++ b/absl/strings/CMakeLists.txt
@@ -410,6 +410,7 @@ absl_cc_library(
absl::strings
absl::config
absl::core_headers
+ absl::numeric_representation
absl::type_traits
absl::int128
absl::span
diff --git a/absl/strings/internal/str_format/float_conversion.cc b/absl/strings/internal/str_format/float_conversion.cc
index 2b1fd8cb..b1c40684 100644
--- a/absl/strings/internal/str_format/float_conversion.cc
+++ b/absl/strings/internal/str_format/float_conversion.cc
@@ -29,6 +29,7 @@
#include "absl/meta/type_traits.h"
#include "absl/numeric/bits.h"
#include "absl/numeric/int128.h"
+#include "absl/numeric/internal/representation.h"
#include "absl/strings/numbers.h"
#include "absl/types/optional.h"
#include "absl/types/span.h"
@@ -39,6 +40,8 @@ namespace str_format_internal {
namespace {
+using ::absl::numeric_internal::IsDoubleDouble;
+
// The code below wants to avoid heap allocations.
// To do so it needs to allocate memory on the stack.
// `StackArray` will allocate memory on the stack in the form of a uint32_t
@@ -112,13 +115,6 @@ inline uint64_t DivideBy10WithCarry(uint64_t *v, uint64_t carry) {
return next_carry % divisor;
}
-constexpr bool IsDoubleDouble() {
- // This is the `double-double` representation of `long double`.
- // We do not handle it natively. Fallback to snprintf.
- return std::numeric_limits<long double>::digits ==
- 2 * std::numeric_limits<double>::digits;
-}
-
using MaxFloatType =
typename std::conditional<IsDoubleDouble(), double, long double>::type;
@@ -1404,6 +1400,8 @@ bool FloatToSink(const Float v, const FormatConversionSpecImpl &conv,
bool ConvertFloatImpl(long double v, const FormatConversionSpecImpl &conv,
FormatSinkImpl *sink) {
if (IsDoubleDouble()) {
+ // This is the `double-double` representation of `long double`. We do not
+ // handle it natively. Fallback to snprintf.
return FallbackToSnprintf(v, conv, sink);
}