summaryrefslogtreecommitdiff
path: root/absl/strings
Commit message (Collapse)AuthorAge
* Remove obsolete TODOGravatar Abseil Team2024-06-04
| | | | | PiperOrigin-RevId: 640138527 Change-Id: I650dd91d76824cfd3a57b36eca282f41b3667125
* Workaround symbol resolution bug in Clang 19Gravatar Derek Mauro2024-05-24
| | | | | | | | | | | | | | Clang 19 seems to see the old usage of absl::string_internal::HasAbslStringify in GoogleTest 1.14.0 and incorrectly resolves absl::HasAbslStringify sometimes. This issue is fixed when a version of GoogleTest that removes absl::string_internal::HasAbslStringify is used. This workaround is ugly but will be removed after the next GoogleTest release. PiperOrigin-RevId: 636993564 Change-Id: Ic166edbd4ddc2c716afbedec34be629cfc988e00
* Silence a bogus GCC14 -Warray-bounds warningGravatar Derek Mauro2024-05-24
| | | | | PiperOrigin-RevId: 636990118 Change-Id: Ib90ed852b899a976679a8eb6352a9161c27e17ce
* PR #1672: Optimize StrJoin with tuple without user defined formatterGravatar Valery Mironov2024-05-15
| | | | | | | | | | | | | | Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1672 https://github.com/abseil/abseil-cpp/discussions/1671 Merge ddcbb2466b2c9c4048d60be7e58cf47f935c257d into eba8db7baf6c326870f28e58977075b7b2fb243d Merging this change closes #1672 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1672 from MBkkt:optimize-str-join ddcbb2466b2c9c4048d60be7e58cf47f935c257d PiperOrigin-RevId: 633988391 Change-Id: I2b3904211a29de3a768fb90a7fc106d7ff6c03e7
* Add a `string_view` overload to `absl::StrJoin`Gravatar Derek Mauro2024-05-13
| | | | | | | | | | | | | | | | | This allows users to pass a collection of string-like objects in an `initializer_list` without having to convert everything to the same type first. `initializer_list` has the requirement that everything is copied in to the list. For strings hitting the `string_view` overload avoids unnecessary copies. This may be a breaking change if `absl::StrJoin` has an explicit template parameter, for example `absl::StrJoin<std::string>({foo, "bar"});`. In this case, remove the explicit template parameter. PiperOrigin-RevId: 633295575 Change-Id: Ie5f0860f409f639a27a58949842ec961e0b3bdeb
* `convert_test`: Delete obsolete condition around ASSERT_EQ in ↵Gravatar Dino Radakovic2024-05-10
| | | | | | | | | TestWithMultipleFormatsHelper The `if (actual != expected)` makes the `ASSERT_EQ(actual, expected)` trigger only when the assertion fails. However, a successful `ASSERT_EQ` takes a negligible amount of time, which means the `if` is useless and only makes the test harder to read. PiperOrigin-RevId: 632487285 Change-Id: I1f78136cf4895295c88a5ff3e0bcdce6b08c1d0b
* Doc fix.Gravatar Abseil Team2024-05-06
| | | | | PiperOrigin-RevId: 631211391 Change-Id: I68bb19d5702626ac497b05d851936aec42cc99d4
* `convert_test`: Extract loop over tested floats from helper functionGravatar Dino Radakovic2024-05-06
| | | | | | | | | | This change is a step towards simplifying `TestWithMultipleFormatsHelper` to the point where we'll be able to handle special cases (e.g. apple's handling of nan) by changing which inputs are fed into the helper, instead of skipping them within the helper and not testing them at all. Extracting the loop also improves readability by reducing indentation. PiperOrigin-RevId: 631038465 Change-Id: I8b2458539d9d276093d8e7b5f373efba6a33800c
* Enable Cord tests with Crc.Gravatar Fergus Henderson2024-04-30
| | | | | PiperOrigin-RevId: 629403229 Change-Id: I24762df161f8a0ea41e59765ec68273f8607166b
* Guard against null pointer dereference in DumpNode.Gravatar Fergus Henderson2024-04-25
| | | | | PiperOrigin-RevId: 628134930 Change-Id: I6b9763f2a87a9259963f00815c6953927f8add73
* Remove the hand-rolled CordLeaker and replace with absl::NoDestructorGravatar Derek Mauro2024-04-24
| | | | | | | to test the after-exit behavior PiperOrigin-RevId: 627804039 Change-Id: Idc1c5fc14cea466dcc98f0d8746c02cafe887502
* `convert_test`: Delete obsolete `skip_verify` parameter in test helperGravatar Dino Radakovic2024-04-24
| | | | | | | | It is unused. We already use code within the `TestWithMultipleFormatsHelper` to skip output verification for Apple and MSVC. PiperOrigin-RevId: 627783586 Change-Id: Ib51374e8571aa5f4b5f1e836815188bd9bdc1536
* Minor cleanup for `absl::Cord`Gravatar Abseil Team2024-04-18
| | | | | PiperOrigin-RevId: 626124196 Change-Id: I81a9e4c35d6456ab8cd3942f9c2452c70db90678
* Add `absl::AppendCordToString`Gravatar Abseil Team2024-04-18
| | | | | PiperOrigin-RevId: 626039936 Change-Id: I6e791363bab06d66029a8565c42d158a2fe176f0
* `str_format/convert_test`: Delete workaround for [glibc ↵Gravatar Dino Radakovic2024-04-18
| | | | | | | | | bug](https://sourceware.org/bugzilla/show_bug.cgi?id=22142) RHEL7 ships an affected version of glibc, but this bug is specific to powerpc, which abseil [does not support](https://github.com/google/oss-policies-info/blob/4ec9f2a979a6c6b7bb148040347c8d2b1def09fa/foundational-cxx-support-matrix.md). PiperOrigin-RevId: 626018125 Change-Id: I1875aee6c37e69f712ef91e41da455af9d00fb5f
* Restore string_view detection checkGravatar Abseil Team2024-04-09
| | | | | PiperOrigin-RevId: 623195368 Change-Id: Iadb9bdedee4d9b5ced4fff9e6316ee63f9a89ea5
* Add ABSL_ATTRIBUTE_LIFETIME_BOUND to Cord::Flatten/TryFlatGravatar Abseil Team2024-04-04
| | | | | | | These were already on the declarations, but it seems like the definitions need them as well. PiperOrigin-RevId: 621868985 Change-Id: I2595aae506924f8b1dad3b07efe1660ae0e4488e
* Temporarily revert dangling std::string_view detection until dependent is fixedGravatar Abseil Team2024-04-02
| | | | | PiperOrigin-RevId: 621413395 Change-Id: I20e9fac94e81e59c0d723f115670c8cf68e9b44a
* Add internal traits to absl::string_view for lifetimebound detectionGravatar Abseil Team2024-04-02
| | | | | | | | | This helps compilers that understand `ABSL_ATTRIBUTE_LIFETIME_BOUND` flag constructs such as `absl::StatusOr<std::string_view> str = std::string(...)` as error-prone. PiperOrigin-RevId: 621196818 Change-Id: I78d4c66854cde9d06eaaec05869d956376109d9c
* Use local decoding buffer in HexStringToBytesGravatar Abseil Team2024-03-28
| | | | | PiperOrigin-RevId: 620141661 Change-Id: I9dc9243b1d227f7cf32319bc1fec94aba850d4c1
* Revert integer-to-string conversion optimizations pending more thorough analysisGravatar Abseil Team2024-03-26
| | | | | PiperOrigin-RevId: 619261152 Change-Id: Id3409b326c52ace0fda42537e0b91dbb2d6a2287
* Fix a bug in `Cord::{Append,Prepend}(CordBuffer)`: callGravatar Marcin Kowalczyk2024-03-26
| | | | | | | | | | | `MaybeRemoveEmptyCrcNode()`. Otherwise appending a `CordBuffer` an empty Cord with a CRC node crashes (`RemoveCrcNode()` which increases the refcount of a nullptr child). Cosmetics: in `Cord::InlineRep::AppendArray()`, return early for empty `src` before removing the empty CRC node. PiperOrigin-RevId: 619107278 Change-Id: I4f1bc6b75c662f4678c61e3ef310e8597d62e2e1
* LSC: Move expensive variables on their last use to avoid copies.Gravatar Abseil Team2024-03-24
| | | | | PiperOrigin-RevId: 618650101 Change-Id: I6cff17a9db0dc45ad3b1f833df6ea3d7d04a7449
* Performance improvement for absl::AsciiStrToUpper() and absl::AsciiStrToLower()Gravatar Abseil Team2024-03-20
| | | | | PiperOrigin-RevId: 617613544 Change-Id: I526b5bc087edf54046c77795dddf5412478ac6a8
* Remove vestigial variables in the DumpNode() helper in absl::CordGravatar Derek Mauro2024-03-19
| | | | | | | Fixes #1636 (GCC -Wmaybe-uninitialized warning) PiperOrigin-RevId: 617253727 Change-Id: I246cd21d8123d4dfa7780b1c4cac8ea1558a4067
* Add explicit #include directives for <tuple>, "absl/base/config.h", and ↵Gravatar Abseil Team2024-03-19
| | | | | | | "absl/strings/string_view.h". PiperOrigin-RevId: 617232899 Change-Id: I5e6c0bd4545d7f7ad9c5c494017269e247f620a3
* Record sampling stride in cord profiling to facilitate unsampling.Gravatar Chris Kennelly2024-03-18
| | | | | | | | The sampling rate may change over time, so this allows us to weight samples by the value observed when we made the sampling decision. PiperOrigin-RevId: 616900100 Change-Id: I9b1affdba93f5f48367cb7503916296b2d84709a
* Add additional checks for size_t overflowsGravatar Derek Mauro2024-03-14
| | | | | | | | | This change mainly affects 32-bit platforms. Similar to 4618865caf8596742a9fd7c28a70a46b5e277794, check for size_t overflow in all places where string result sizes are precomputed before allocation. PiperOrigin-RevId: 615792028 Change-Id: I71c774c5ef2c2978bd812c70e9bab36d266b7c90
* Work around an implicit conversion signedness compiler warningGravatar Abseil Team2024-03-07
| | | | | | | | | | | Addition and subtraction operators std::array::iterator are defined only for ptrdiff_t, which is signed, instead of size_t, which is unsigned. Therefore, adding the index variable to ar.begin() will trigger -Wsign-conversion if std::array::iterator is not a raw pointer because the index variable will be implicitly converted from size_t (an unsigned type) to ptrdiff_t (a signed type). To fix this, we explicitly static_cast index to a ptrdiff_t. PiperOrigin-RevId: 613662928 Change-Id: I5e06c2261d7b8f167fae7bb6acece076257f8579
* Automated Code ChangeGravatar Abseil Team2024-02-28
| | | | | PiperOrigin-RevId: 611321915 Change-Id: Ia63e3e2f66981d9e4f5b97f6df276b8195459ba2
* Workaround for NVIDIA C++ compiler being unable to parse variadic expansions ↵Gravatar Abseil Team2024-02-28
| | | | | | | | in range of range-based for loop Fixes: #1629 PiperOrigin-RevId: 611131201 Change-Id: I787731e00207b544ee16055e6e0d323a5094a433
* Performance improvement for absl::AsciiStrToUpper() and absl::AsciiStrToLower()Gravatar Abseil Team2024-02-20
| | | | | PiperOrigin-RevId: 608770171 Change-Id: Icca54086037e42826c272f04374aeb33d060ace5
* Performance improvement for absl::AsciiStrToUpper() and absl::AsciiStrToLower()Gravatar Abseil Team2024-02-20
| | | | | PiperOrigin-RevId: 608661989 Change-Id: Ibfd94f8b2d23fd232bf93904ed68e11a400b3644
* Minor documentation fix for `absl::StrSplit()`Gravatar Abseil Team2024-02-14
| | | | | PiperOrigin-RevId: 607095897 Change-Id: I077857f0b4c5cf8bbc62bfc8e51a20bb6845296c
* Prevent overflow in `absl::CEscape()`Gravatar Derek Mauro2024-02-14
| | | | | | | | | | | | | | | | | | Strings larger than 1 GiB on a platform with a 32-bit size_t could potentially overflow size_t in `CEscapedLength()`, resulting in an undersized allocation. The resulting write in `CEscapeAndAppendInternal()` would then write beyond the bounds of the output buffer. A second overflow, where the calculated escaped length is added to the size of the string being appended to, is also fixed. In both cases the program will now abort prior to the overflow. Credit goes to Ronald Crane (Zippenhop LLC) for reporting this issue. PiperOrigin-RevId: 607019573 Change-Id: I97bf246cde96102a793d2db49446cccae08abf59
* Switch rank structs to be consistent with written guidance in ↵Gravatar Matt Kulukundis2024-02-07
| | | | | | | go/ranked-overloads PiperOrigin-RevId: 605125821 Change-Id: I2ee260eaf283acafd80abfd2b7419a0e9f597a78
* Stop using `std::basic_string<uint8_t>` which relies on a non-standard genericGravatar Bogdan Graur2024-02-07
| | | | | | | `char_traits<>` implementation, recently removed from `libc++`. PiperOrigin-RevId: 605023824 Change-Id: Ia708c91c24625afc4504fa77e959f8ed1e025589
* Add a version of absl::HexStringToBytes() that returns a boolGravatar Derek Mauro2024-02-05
| | | | | | | | | | | | to validate that the input was actually valid hexadecimal data. Mark the version of absl::HexStringToBytes() that does not validate the input as deprecated. Fixes #141 PiperOrigin-RevId: 604495678 Change-Id: Iac3020c33c9dbc6d8e31a43b746783fb345edaa7
* Optimize `Cord::Swap()` for missed compiler optimization in clang.Gravatar Martijn Vels2024-02-01
| | | | | PiperOrigin-RevId: 603342563 Change-Id: I1cd80103377f457770d5178dad8b56ae459cbd55
* Replace `testonly = 1` with `testonly = True` in abseil BUILD files.Gravatar Shahriar Rouf2024-01-31
| | | | | | | https://bazel.build/build/style-guide#other-conventions PiperOrigin-RevId: 603084345 Change-Id: Ibd7c9573d820f88059d12c46ff82d7d322d002ae
* Missing parenthesis.Gravatar Abseil Team2024-01-30
| | | | | PiperOrigin-RevId: 602864815 Change-Id: I74db20c93f6a7d9046779677cb4a328dc54bae69
* Use absl::NoDestructor for cordz global queue.Gravatar Abseil Team2024-01-30
| | | | | | | Also updated the return value to reference to clarify non-nullability. PiperOrigin-RevId: 602730828 Change-Id: Ia36f7fde3cc87ac597ba4f194eebe9ebb90a1a09
* Fix a corner case in SpyHashState for exact boundaries.Gravatar Matt Kulukundis2024-01-29
| | | | | | | AbslHash allows for piecewise chunks to be streamed incrementally into hash states and requires them to hash identically to one giant stream. The exact size window for this is an internal details `PiecewiseChunkSize`. There was an off by one error in this code. Add tests and fix it. PiperOrigin-RevId: 602463183 Change-Id: I159bbb5e7e745f55b2fe6eaf0d2735bd0a08aca9
* Add nullability annotationsGravatar Dmitri Gribenko2024-01-25
| | | | | PiperOrigin-RevId: 601477629 Change-Id: I3b683d94192b04f233ce5ec636586ccb90d24602
* Prevent brace initialization of AlphaNumGravatar Abseil Team2024-01-19
| | | | | | | | | This was not intended to be supported, and it has resulted in calls as `absl::StrCat({...})`, which are not supported and only work coincidentally for the first 4 arguments due to `absl::StrCat` having overloads that take `absl::AlphaNum` directly for those. The existing situation prevents modifying the implementations of such functions to alternatives that do not have such overloads for those arguments. PiperOrigin-RevId: 599872755 Change-Id: I02c90119b2b96a922cf7e3b5d5f02affe24a272d
* Remove code pieces for no longer supported MSVC versions.Gravatar Abseil Team2024-01-19
| | | | | | | The current support policy is `_MSC_VER >= 1920`. PiperOrigin-RevId: 599833619 Change-Id: I9cf7393a5b659d1680765e37e0328539ccb870fa
* Re-add the internal file //absl/string/internal/has_absl_stringify.h to unblockGravatar Derek Mauro2024-01-09
| | | | | | | | | | | | | | | releasing Abseil and GoogleTest. GoogleTest referenced this internal file and this internal trait. Since simultaneous releases are not possible since once release must reference another, we will temporarily add this back. https://github.com/google/googletest/blob/v1.14.x/googletest/include/gtest/gtest-printers.h#L119 https://github.com/google/googletest/pull/4368#issuecomment-1717699895 https://github.com/google/googletest/pull/4368#issuecomment-1717699895 PiperOrigin-RevId: 597073935 Change-Id: I7c2697a212dc477fd25770777445c64cfee73745
* Extend BM_StrAppendInt to use log-uniform random numbers instead of constantsGravatar Abseil Team2024-01-05
| | | | | | | | | This follows Benford's law, which is likely also a much more accurate representation of real data than a constant. We also add benchmarks for different integer types. PiperOrigin-RevId: 596039508 Change-Id: I4862c7cfdbf5face18ae31cf0bd2fd54e47684b7
* Optimize integer-to-string conversionsGravatar Abseil Team2024-01-04
| | | | | | | | | | | | | | | | | | | | | | 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
* Correct nullability annotations on MakeNanGravatar Abseil Team2024-01-04
| | | | | | | Neither GCC nor Clang's __builtin_nan(), nor glibc's nan(), accept null pointers. PiperOrigin-RevId: 595767225 Change-Id: I4cddd1cafd0c9e83a823ec68386f10ce077c6b4c