summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2024-01-04 13:14:50 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2024-01-04 13:15:44 -0800
commitd5a2cec006d14c6801ddeb768bf2574a1cf4fa7f (patch)
tree3dc1ffb00d164ddda4c22b8abfc42594db1fa2da /absl/base
parentccf0c7730db976d2b7814e74f6f01d044ae6f853 (diff)
Optimize integer-to-string conversions
The updated code is designed to: - Be branch-predictor-friendly - Be cache-friendly - Minimize the lengths of critical paths - Minimize slow operations (particularly multiplications) - Minimize binary/codegen bloat The most notable performance trick here is perhaps the precomputation & caching of the number of digits, so that we can reuse/exploit it when writing the output. This precomputation of the exact length enables 2 further performance benefits: - It makes `StrCat` and `StrAppend` zero-copy when only integers are passed, by avoiding intermediate `AlphaNum` entirely in those cases. If needed in the future, we can probably also make many other mixtures of non-integer types zero-copy as well. - It avoids over-reservation of the string buffer, allowing for more strings to fit inside SSO, which will likely have further performance benefits. There is also a side benefit of preventing `FastIntToBuffer` from writing beyond the end of the buffer, which has caused buffer overflows in the past. The new code continues to use & extend some of the existing core tricks (such as the division-by-100 trick), as those are already efficient. PiperOrigin-RevId: 595785531 Change-Id: Id6920e7e038fec10b2c45f213de75dc7e2cbddd1
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/macros.h12
1 files changed, 0 insertions, 12 deletions
diff --git a/absl/base/macros.h b/absl/base/macros.h
index cd7cf498..f33cd192 100644
--- a/absl/base/macros.h
+++ b/absl/base/macros.h
@@ -138,16 +138,4 @@ ABSL_NAMESPACE_END
#define ABSL_INTERNAL_RETHROW do {} while (false)
#endif // ABSL_HAVE_EXCEPTIONS
-// Requires the compiler to prove that the size of the given object is at least
-// the expected amount.
-#if ABSL_HAVE_ATTRIBUTE(diagnose_if) && ABSL_HAVE_BUILTIN(__builtin_object_size)
-#define ABSL_INTERNAL_NEED_MIN_SIZE(Obj, N) \
- __attribute__((diagnose_if(__builtin_object_size(Obj, 0) < N, \
- "object size provably too small " \
- "(this would corrupt memory)", \
- "error")))
-#else
-#define ABSL_INTERNAL_NEED_MIN_SIZE(Obj, N)
-#endif
-
#endif // ABSL_BASE_MACROS_H_