aboutsummaryrefslogtreecommitdiff
path: root/absl/strings
Commit message (Collapse)AuthorAgeFilesLines
* Record sampling stride in cord profiling to facilitate unsampling.Chris Kennelly2024-03-189-71/+95
| | | | | | | | 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 overflowsDerek Mauro2024-03-144-12/+56
| | | | | | | | | 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 warningAbseil Team2024-03-071-1/+5
| | | | | | | | | | | 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 ChangeAbseil Team2024-02-281-0/+2
| | | | | PiperOrigin-RevId: 611321915 Change-Id: Ia63e3e2f66981d9e4f5b97f6df276b8195459ba2
* Workaround for NVIDIA C++ compiler being unable to parse variadic expansions ↵Abseil Team2024-02-281-12/+11
| | | | | | | | in range of range-based for loop Fixes: #1629 PiperOrigin-RevId: 611131201 Change-Id: I787731e00207b544ee16055e6e0d323a5094a433
* Performance improvement for absl::AsciiStrToUpper() and absl::AsciiStrToLower()Abseil Team2024-02-201-8/+63
| | | | | PiperOrigin-RevId: 608770171 Change-Id: Icca54086037e42826c272f04374aeb33d060ace5
* Performance improvement for absl::AsciiStrToUpper() and absl::AsciiStrToLower()Abseil Team2024-02-201-63/+8
| | | | | PiperOrigin-RevId: 608661989 Change-Id: Ibfd94f8b2d23fd232bf93904ed68e11a400b3644
* Minor documentation fix for `absl::StrSplit()`Abseil Team2024-02-141-1/+1
| | | | | PiperOrigin-RevId: 607095897 Change-Id: I077857f0b4c5cf8bbc62bfc8e51a20bb6845296c
* Prevent overflow in `absl::CEscape()`Derek Mauro2024-02-141-4/+22
| | | | | | | | | | | | | | | | | | 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 ↵Matt Kulukundis2024-02-072-6/+7
| | | | | | | go/ranked-overloads PiperOrigin-RevId: 605125821 Change-Id: I2ee260eaf283acafd80abfd2b7419a0e9f597a78
* Stop using `std::basic_string<uint8_t>` which relies on a non-standard genericBogdan Graur2024-02-071-6/+5
| | | | | | | `char_traits<>` implementation, recently removed from `libc++`. PiperOrigin-RevId: 605023824 Change-Id: Ia708c91c24625afc4504fa77e959f8ed1e025589
* Add a version of absl::HexStringToBytes() that returns a boolDerek Mauro2024-02-053-1/+84
| | | | | | | | | | | | 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.Martijn Vels2024-02-012-1/+22
| | | | | PiperOrigin-RevId: 603342563 Change-Id: I1cd80103377f457770d5178dad8b56ae459cbd55
* Replace `testonly = 1` with `testonly = True` in abseil BUILD files.Shahriar Rouf2024-01-311-4/+4
| | | | | | | https://bazel.build/build/style-guide#other-conventions PiperOrigin-RevId: 603084345 Change-Id: Ibd7c9573d820f88059d12c46ff82d7d322d002ae
* Missing parenthesis.Abseil Team2024-01-301-1/+1
| | | | | PiperOrigin-RevId: 602864815 Change-Id: I74db20c93f6a7d9046779677cb4a328dc54bae69
* Use absl::NoDestructor for cordz global queue.Abseil Team2024-01-303-25/+26
| | | | | | | 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.Matt Kulukundis2024-01-293-0/+23
| | | | | | | 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 annotationsDmitri Gribenko2024-01-252-23/+40
| | | | | PiperOrigin-RevId: 601477629 Change-Id: I3b683d94192b04f233ce5ec636586ccb90d24602
* Prevent brace initialization of AlphaNumAbseil Team2024-01-191-0/+5
| | | | | | | | | 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.Abseil Team2024-01-192-5/+1
| | | | | | | 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 unblockDerek Mauro2024-01-093-0/+46
| | | | | | | | | | | | | | | 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 constantsAbseil Team2024-01-052-33/+47
| | | | | | | | | 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 conversionsAbseil Team2024-01-046-200/+759
| | | | | | | | | | | | | | | | | | | | | | 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 MakeNanAbseil Team2024-01-041-2/+2
| | | | | | | Neither GCC nor Clang's __builtin_nan(), nor glibc's nan(), accept null pointers. PiperOrigin-RevId: 595767225 Change-Id: I4cddd1cafd0c9e83a823ec68386f10ce077c6b4c
* Avoid a empty library build failure on Apple platformsDerek Mauro2024-01-031-0/+18
| | | | | | | | | | | | | | | | | | | | | https://github.com/abseil/abseil-cpp/issues/1465 reports that some CMake builds on Apply platforms issue ``` warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive library: libabsl_bad_any_cast_impl.a the table of contents is empty (no object file members in the library define global symbols) ``` Our CMake build handles this problem for header-only libraries by not building a library at all. For some libraries, for example our polyfills, the library is only conditionally empty. In these libraries, I added a single char variable on Apple platforms as a workaround. I have been able to reproduce the warnings reported in https://github.com/abseil/abseil-cpp/issues/1465, but they don't fail the build for me. I don't see them any more after this change. PiperOrigin-RevId: 595480705 Change-Id: Ie48637e84ebae2f2aea4e2de83b146f30f6a76b9
* Add compile-checks to ensure the parameter to ↵Abseil Team2023-12-281-6/+12
| | | | | | | | | absl::numbers_internal::FastIntToBuffer isn't provably insufficient This performance-sensitive API is internal, and should not be used directly. Nevertheless, some do use it, so it's worth trying to block incorrect uses where we can. PiperOrigin-RevId: 594289730 Change-Id: Ib5df39b450ef2ceda795082cde10ec2ba2642172
* Performance improvement for absl::AsciiStrToUpper() and absl::AsciiStrToLower()Abseil Team2023-12-202-5/+65
| | | | | PiperOrigin-RevId: 592664369 Change-Id: I7aa7b045c2b3c0f25cff7b82eb9d9cc13e9fc49f
* Added ByAsciiWhitespace to str_split library.Abseil Team2023-12-203-0/+63
| | | | | PiperOrigin-RevId: 592653487 Change-Id: Iddd2f484807cb02dd2ee8bba26c22d196be02c88
* Add a pragma to disable a stringop-overflow warning for GCC12+Abseil Team2023-12-181-0/+8
| | | | | PiperOrigin-RevId: 591894838 Change-Id: Ib3fe72d255f49320e2728c210ba1faabc81e0ef8
* Roll back changes to AsciiStrToUpper() and AsciiStrToLower() due to bug report.Abseil Team2023-12-142-61/+5
| | | | | PiperOrigin-RevId: 591161019 Change-Id: Iae2477a24819e20288fbb83b4a343031af71f1bb
* Performance improvement for absl::AsciiStrToUpper() and absl::AsciiStrToLower()Abseil Team2023-12-142-5/+61
| | | | | PiperOrigin-RevId: 591015112 Change-Id: I3e654433f0b0a4ea02ee10e0894e70738e730782
* Add nullability annotationsDmitri Gribenko2023-12-1123-381/+525
| | | | | PiperOrigin-RevId: 589842893 Change-Id: I9657761d1f71c665582406f278c6605f6d382f6d
* Fixing a comment to be correct with the current code.Abseil Team2023-12-061-2/+2
| | | | | PiperOrigin-RevId: 588530709 Change-Id: Iee28c7693a4802f11e13728e1c28febee8c8576f
* Adds support for wchar_t/wchar_t*/std::wstring{_view} arguments to StrFormat().Abseil Team2023-12-0514-107/+608
| | | | | | | This converts to UTF-8 regardless of locale. PiperOrigin-RevId: 588186076 Change-Id: I2c9598279b413d460e13ad65da2ba421c0b40b83
* Update documentation to reflect best practices (prefer brace initialization)Abseil Team2023-11-271-3/+3
| | | | | PiperOrigin-RevId: 585691325 Change-Id: Icd18dc0294dfd1e22f9878b628d5e5898fcc8185
* Fixed a very small typo in the Cord::empty() docstring.Abseil Team2023-11-141-1/+1
| | | | | PiperOrigin-RevId: 582455513 Change-Id: Ic78d14d6dd748420a64e7026ec7f8b967bebbf42
* Add new benchmark for integer `StrAppend`Abseil Team2023-11-131-1/+23
| | | | | PiperOrigin-RevId: 582033534 Change-Id: I9af42210f65b40ccd7f55c9a2e0c8387b69760dc
* Doc fix.Abseil Team2023-11-031-2/+2
| | | | | PiperOrigin-RevId: 579263069 Change-Id: I78678c2fc6aba4851f8a06dafb695c913accf0d0
* Optimize memcasecmp. Benchmarks shows slight improvement.Ilya Tokar2023-10-301-4/+12
| | | | | | | | | | | | | | | We are also avoiding potential cache-misses, by avoiding load. name old speed new speed delta BM_Searchcase 3.09GB/s ±13% 3.20GB/s ±16% +3.69% (p=0.039 n=20+17) BM_SearchcaseMedium 1.08GB/s ± 7% 1.04GB/s ±14% ~ (p=0.814 n=16+20) BM_SearchcasePathological 618kB/s ±13% 652kB/s ± 6% +5.55% (p=0.043 n=20+16) BM_Memcasematch 2.43GB/s ± 3% 2.45GB/s ± 3% ~ (p=0.488 n=17+16) BM_MemcasematchMedium 230MB/s ± 8% 261MB/s ±14% +13.77% (p=0.000 n=16+20) BM_MemcasematchPathological 624kB/s ±14% 619kB/s ±14% ~ (p=0.836 n=20+20) PiperOrigin-RevId: 577919033 Change-Id: I31324e04b6a577c582ad630d171d3b41d826f1e4
* Fix an unreachable code warning on some platformsDerek Mauro2023-10-301-2/+9
| | | | | | | #1558 PiperOrigin-RevId: 577874842 Change-Id: I1d56f3f4b445f6c4a9df2fe06fec542cb00e0e92
* Fix a typo.Abseil Team2023-10-241-1/+1
| | | | | PiperOrigin-RevId: 576162408 Change-Id: Ib383bb744b5cb11b6cbc99f2323583e1d23d8ff1
* Add `AbslStringify()` support to `absl::Cord`Abseil Team2023-10-243-0/+16
| | | | | PiperOrigin-RevId: 576149980 Change-Id: I0a7e3df7a01edc78ee5d15d8d8e82e7bbc5fc0f3
* Performance improvements for `absl::AsciiStrToLower` and ↵Abseil Team2023-10-232-11/+29
| | | | | | | `absl::AsciiStrToUpper`. PiperOrigin-RevId: 575969640 Change-Id: If6ddc0a71debfe571c2739ec91fc99594bc36f88
* absl::string_view: Add support for starts_with() and ends_with()Derek Mauro2023-10-202-1/+123
| | | | | | | | | | | | | | | | when targeting at least C++20 These methods were added to C++20, so they are not available in earlier language standards. Users requiring compatibility prior to C++20 should use absl::StartsWith() and absl::EndsWith() from //absl/strings/match.h. Most users are not affected by this change. By default when targeting at least C++20 absl::string_view will be an alias for std::string_view. Only users that have modified //absl/base/options.h will see this change. PiperOrigin-RevId: 575238435 Change-Id: I7b03fde02c987b30b88c794640c2a616851997d1
* Add a template gadget to detect whether a type supports the ostream operator.Zie Weaver2023-10-185-0/+137
| | | | | | | | | | I.e. for a type `Example`, if ``` std::ostream& operator<<(std::ostream&, const Example&); ``` is declared, `absl::HasOstreamOperator<Example>::value` is `true`. PiperOrigin-RevId: 574637891 Change-Id: I123d8f35a6e3ea894745133f7d81b1610fb475d5
* Delete `absl::strings_internal::HasAbslStringify`.Abseil Team2023-10-123-46/+0
| | | | | | | Users should use `absl::HasAbslStringify` instead. PiperOrigin-RevId: 572916854 Change-Id: Ie67e076e0335b108d23f886a28074f7557ba045a
* Bazel: Enable the header_modules featureDerek Mauro2023-10-111-0/+1
| | | | | PiperOrigin-RevId: 572575394 Change-Id: Ic1c5ac2423b1634e50c43bad6daa14e82a8f3e2c
* Bazel: Support layering_check and parse_headersDerek Mauro2023-10-101-1/+63
| | | | | | | | | | | | | The layering_check feature ensures that rules that include a header explicitly depend on a rule that exports that header. Compiler support is required, and currently only Clang 16+ supports diagnoses layering_check failures. The parse_headers feature ensures headers are self-contained by compiling them with -fsyntax-only on supported compilers. PiperOrigin-RevId: 572350144 Change-Id: I37297f761566d686d9dd58d318979d688b7e36d1
* Update argument order of `EXPECT_EQ` in `absl::StrJoin` documentation.Abseil Team2023-10-061-13/+13
| | | | | PiperOrigin-RevId: 571487219 Change-Id: I6fbb2ff19db2b6d77e55059004d65c8639eb7fca
* Fix a crash when calling `EstimatedMemoryUsage()` on an empty checksummed ↵Abseil Team2023-09-222-0/+9
| | | | | | | `absl::Cord`. PiperOrigin-RevId: 567695227 Change-Id: I13eb8a1872d2fe703b5f3b9bc8df7fec4381fb55