summaryrefslogtreecommitdiff
path: root/absl/strings
Commit message (Collapse)AuthorAge
* Updated documentation on use of %vGravatar Tom Manshreck2022-11-15
| | | | | | | Also updated documentation around FormatSink and PutPaddedString PiperOrigin-RevId: 488651398 Change-Id: Ic6c586dbb8bea61df841a142f12d22c7e5b03f43
* Add support for enum types with AbslStringifyGravatar Abseil Team2022-11-09
| | | | | PiperOrigin-RevId: 487394692 Change-Id: I55e9b57055483dc921e9773c3643ea9be4f9bdf6
* Support logging of user-defined types that implement `AbslStringify()`Gravatar Phoebe Liang2022-11-02
| | | | | | | | | If a user-defined type has `AbslStringify()` defined, it will always be used for logging over `operator<<`. `HasAbslStringify` now uses the empty class `UnimplementedSink` for its checks instead of `StringifySink` in order to make it work in cases involving other sinks. PiperOrigin-RevId: 485710377 Change-Id: Ibdd916151c7abc3269c35fbe79b772867f3d25e1
* Fix -Wimplicit-int-conversion.Gravatar Abseil Team2022-11-02
| | | | | PiperOrigin-RevId: 485575914 Change-Id: If1752252e3cc2f91dc3c171382c9fb3a4def0377
* Cord: Avoid leaking a node if SetExpectedChecksum() is called on anGravatar Derek Mauro2022-11-01
| | | | | | | empty cord twice in a row. PiperOrigin-RevId: 485367641 Change-Id: I6605ff25acbcef7c40b68e15a8888076a2da63be
* Support empty Cords with an expected checksumGravatar Derek Mauro2022-10-28
| | | | | PiperOrigin-RevId: 484578104 Change-Id: Ie4be3e4de27dc28d88395e16fd075fb10ab7a302
* Move internal details from one source file to another more appropriate sourceGravatar Andy Soffer2022-10-27
| | | | | | | file. PiperOrigin-RevId: 484419458 Change-Id: Ic2c1afa1a3434ac071c01ae2e6c75dee41b1f069
* Removes `PutPaddedString()` functionGravatar Phoebe Liang2022-10-27
| | | | | | | This function is unnecessary as it was originally used to support modifiers with `absl::StrFormat()`. This functionality is irrelevant to `absl::StrCat()`. PiperOrigin-RevId: 484339246 Change-Id: I8c4a0ee01b30aee7a83f6ab54e5465465cc9cc56
* Return uint8_t from CappedDamerauLevenshteinDistance.Gravatar Abseil Team2022-10-27
| | | | | PiperOrigin-RevId: 484181180 Change-Id: I00206c1506a25dca5555261d6500c1e54368a368
* Document Base64Unescape() paddingGravatar Abseil Team2022-10-21
| | | | | PiperOrigin-RevId: 482905442 Change-Id: Ic3a1e62f8a17efee5508d94835635aa489940f2d
* Fix a sign conversion warning.Gravatar Abseil Team2022-10-19
| | | | | | Bug: chromium:1292951 PiperOrigin-RevId: 482287305 Change-Id: I896033c7c8b2645eacab974c4364c6ba66d38cb6
* Implement function to calculate Damerau-Levenshtein distance between two ↵Gravatar Abseil Team2022-10-17
| | | | | | | strings. PiperOrigin-RevId: 481568970 Change-Id: Icb132348f62fed4c0168aac4963b3313a060890b
* Support stringification of user-defined types in AbslStringify in ↵Gravatar Andy Soffer2022-10-14
| | | | | | | | | | | | | | absl::Substitute. We are also moving some internals into an internal header. `HasAbslStringify` was not previously in an internal namespace but was intended to be and has now been moved to an internal namespace. This is in adherence to our compatibility guidelines which wave requirements for APIs within their first 30 days of public release (See https://abseil.io/about/compatibility for details). PiperOrigin-RevId: 481190705 Change-Id: I4c0c348f269ea8d76ea3d4bd5a2c41cce475dc04
* Fix "unsafe narrowing" warnings in absl, 12/12.Gravatar Abseil Team2022-10-13
| | | | | | | | | | | | | | | Addresses failures with the following, in some files: -Wshorten-64-to-32 -Wimplicit-int-conversion -Wsign-compare -Wsign-conversion -Wtautological-unsigned-zero-compare (This specific CL enables these warnings and fixes the remaining known issues.) Bug: chromium:1292951 PiperOrigin-RevId: 480981210 Change-Id: I92d5023c6833e24d6aa29b10d433116329972f41
* Revert change to internal 'Rep', this causes issues for gdbGravatar Martijn Vels2022-10-13
| | | | | PiperOrigin-RevId: 480945608 Change-Id: I3e90a105c793deee02fbef322946bf7d5340dc78
* Reorganize InlineData into an inner Rep structure.Gravatar Martijn Vels2022-10-13
| | | | | | | | | | | | | | | | This moves inlined code around a bit without changing anything bar the names of things. The purpose for all this is that it greatly simplifies the process of adding memory poisining to Cord / InlineData. InlineData can have scoped poison / unpoison regions around the interface, calling into rep for the 'real code'. I.e.: Rep::as_chars() { return &inline_data[1]; } InlineData::as_chars() { Unpoisoned self(this); return rep_.as_chars(); } Likewise, it greatly simplifies intercepting the code for constructors, copy constructors and operator= logic. PiperOrigin-RevId: 480893031 Change-Id: I050c88caff2315939d95a0361ae20528be36a96b
* Change Cord internal layout, which reduces store-load penalties on ARMGravatar Martijn Vels2022-10-11
| | | | | PiperOrigin-RevId: 480511524 Change-Id: I73945b1150a2e2e75774684fb8e7364f9c1290a7
* Fix a bug in StrFormat. This issue would have been caught by any compile-timeGravatar Andy Soffer2022-10-10
| | | | | | | | | checking but can happen for incorrect formats parsed via ParsedFormat::New. Specifically, if a user were to add length modifiers with 'v', for example the incorrect format string "%hv", the ParsedFormat would incorrectly be allowed. PiperOrigin-RevId: 480183817 Change-Id: I8510c13189fdf807cdaa7f2e1b7ed9fba2aaefb9
* Adds documentation for stringification extensionGravatar Abseil Team2022-10-10
| | | | | PiperOrigin-RevId: 480166410 Change-Id: Ie915e98747ffda0d1f0e5a72383f5dd9fc940970
* Add clang < 7 to conditionsGravatar Randolf J2022-10-05
|
* Merge branch 'abseil:master' into patch-1Gravatar Randolf J2022-10-05
|\
| * Make sinks provided to `AbslStringify()` usable with `absl::Format()`.Gravatar Marcin Kowalczyk2022-10-05
| | | | | | | | | | | | | | | | Such sinks must define ADL-callable `AbslFormatFlush()`. It can just forward to `Append()`. PiperOrigin-RevId: 479043790 Change-Id: I5d7d80ca1e17adf03b77726df8a52e2b4e9196ce
* | Update charconv.ccGravatar Randolf J2022-10-04
| |
* | chore: limit to ClangGravatar Randolf J2022-10-04
| |
| * No changes in OSSGravatar Gennadiy Rozental2022-10-03
| | | | | | | | | | PiperOrigin-RevId: 478668020 Change-Id: Iee79011bf7154e83ad862e7bf6e7a76dd337ec06
| * Replace the kPower10ExponentTable array with a formula.Gravatar Abseil Team2022-10-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sizeof(kPower10ExponentTable) = 651 * sizeof(int16_t) = 1302 bytes. Their equivalence can be confirmed by this test program: ``` const int minIncl = -342; const int maxExcl = 309; const int kPower10ExponentTable[] = { etc }; int Power10Exponent(int n) { return kPower10ExponentTable[n - minIncl]; } int main(int argc, char** argv) { for (int n = minIncl; n < maxExcl; n++) { int formula = (217706 * n >> 16) - 63; int table = Power10Exponent(n); if (formula != table) { return 1; } } return 0; } ``` Tested by atod_manual_test over the parse-number-fxx-test-data test cases, with and without manually disabling the EiselLemire code path, noting that changing the magic 217706 value causes test failures. PiperOrigin-RevId: 478646550 Change-Id: Icaaf106f9aa36e2de057f3bc9aeddc3ae0efade6
| * CMake: Mark absl::cord_test_helpers and absl::spy_hash_state PUBLICGravatar Abseil Team2022-10-03
| | | | | | | | | | PiperOrigin-RevId: 478611460 Change-Id: I327dbd1c16a22649e3a25b9ebbc94b48a2fda26f
* | Update charconv.ccGravatar Randolf J2022-10-02
|/
* Allows absl::StrCat to accept types that implement AbslStringify()Gravatar Abseil Team2022-09-30
| | | | | PiperOrigin-RevId: 478050535 Change-Id: I8e4a4b01aceb8d712476101633eac0ce8647823a
* Cleanup: SmallMemmove nullify should also be limited to 15 bytesGravatar Martijn Vels2022-09-30
| | | | | | | | | The current implementation correctly copies up to 15 bytes of data, but the nullify code clears up to 16 bytes, which was likely motivated by the assumption that the length indicator is always the last byte. This changes limits the nullify to 15 bytes as well removing this layout specific assumption from cord.h, making future platform specific internal layout changes easier to land. PiperOrigin-RevId: 477997741 Change-Id: Idcdfeca2a005139f97eafcc77111542d90b817af
* Cleanup: implement PrependArray and PrependPrecise in terms of InlineDataGravatar Martijn Vels2022-09-29
| | | | | | | This removes layout specific details from InlineData from cord.cc, making future platform specific internal layout changes easier to land. PiperOrigin-RevId: 477870559 Change-Id: I26e428ef280d593ad321cf7875e05adcb1cb6438
* Cleanup: Move BitwiseCompare() to InlineData, and make it layout independent.Gravatar Martijn Vels2022-09-29
| | | | | | | This removes layout specific details from InlineData from cord.h, making future platform specific internal layout changes easier to land. PiperOrigin-RevId: 477869206 Change-Id: I1d417af47d7f04e34a98ba7b93ae591ece8f9151
* Change kPower10Table bounds to be half-openGravatar Abseil Team2022-09-29
| | | | | | | | | | | | Half-open intervals are recommended by Dijkstra: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html This also simplifies a static_assert by removing a +1 term. Also fix a "smaller exponent" copy/pasto. PiperOrigin-RevId: 477848998 Change-Id: I67af73d37ac08d36a1117ba33313a02932bd5814
* Cleanup some InlineData internal layout specific details from cord.hGravatar Martijn Vels2022-09-29
| | | | | | | This makes future platform specific internal layout changes easier to land. PiperOrigin-RevId: 477843948 Change-Id: I4ca4fdea5e965261c029d08319aba0290721c227
* Improve the comments on the implementation of format hooks adl tricks.Gravatar Matt Kulukundis2022-09-29
| | | | | PiperOrigin-RevId: 477811281 Change-Id: Iba838e0eaceb5e6bfe1dac496fc86a22f5cf31d5
* Documentation: Remove an obsolete note about the implementation of `Cord`.Gravatar Abseil Team2022-09-28
| | | | | PiperOrigin-RevId: 477587157 Change-Id: I4527b891222a011f8c1788387479bdc8e4a3bb94
* Allows absl::StrFormat to accept types which implement AbslStringify()Gravatar Abseil Team2022-09-28
| | | | | PiperOrigin-RevId: 477507777 Change-Id: I5ecde3163ca560ac8774034e55654774e36ad230
* Implement Eisel-Lemire for from_chars<float>Gravatar Abseil Team2022-09-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This does for float what a recent commit did for double. Median of 5 runs of "time atod_manual_test pnftd/data/*.txt" user 0m0.730s # Before user 0m0.701s # After (a speed-up of 1.04x) where pnftd is https://github.com/nigeltao/parse-number-fxx-test-data Part of the reason why this speed-up of 1.04x isn't as dramatic as for the from_chars<double> change is that, out of the 5299993 pnftd test cases, 76.42% produce result_out_of_range for single precision (compared to 1.03% for double precision). "benchy --reference=srcfs --benchmark_filter='SimpleAtof' :numbers_benchmark" output (which uses deterministic but randomly generated input strings): name old cpu/op new cpu/op delta BM_SimpleAtof<absl::string_view>/10/1 392ns ± 2% 323ns ± 3% -17.60% (p=0.000 n=48+48) BM_SimpleAtof<absl::string_view>/10/2 426ns ± 3% 311ns ± 4% -26.89% (p=0.000 n=59+49) BM_SimpleAtof<absl::string_view>/10/4 435ns ± 3% 341ns ± 3% -21.68% (p=0.000 n=58+48) BM_SimpleAtof<absl::string_view>/10/8 501ns ± 3% 393ns ± 3% -21.55% (p=0.000 n=60+50) BM_SimpleAtof<const char*>/10/1 409ns ± 6% 339ns ± 3% -17.06% (p=0.000 n=48+49) BM_SimpleAtof<const char*>/10/2 412ns ± 4% 347ns ± 3% -15.82% (p=0.000 n=47+49) BM_SimpleAtof<const char*>/10/4 463ns ± 6% 369ns ± 6% -20.37% (p=0.000 n=60+50) BM_SimpleAtof<const char*>/10/8 548ns ± 3% 450ns ± 4% -17.91% (p=0.000 n=57+59) BM_SimpleAtof<std::string>/10/1 386ns ± 2% 325ns ± 3% -15.74% (p=0.000 n=48+50) BM_SimpleAtof<std::string>/10/2 425ns ± 3% 311ns ± 4% -26.79% (p=0.000 n=60+50) BM_SimpleAtof<std::string>/10/4 435ns ± 4% 340ns ± 3% -21.94% (p=0.000 n=59+49) BM_SimpleAtof<std::string>/10/8 503ns ± 4% 398ns ± 2% -20.89% (p=0.000 n=59+48) PiperOrigin-RevId: 476880111 Change-Id: Ibc5583677ac2ed338d09d8db960ae8a513eb2ccb
* Adds support for "%v" in absl::StrFormat and related functions for bool ↵Gravatar Abseil Team2022-09-20
| | | | | | | values. Note that %v prints bool values as "true" and "false" rather than "1" and "0". PiperOrigin-RevId: 475651689 Change-Id: I24b3749d85b5bb7cbc18653d629271a8b2b07d08
* Explicitly disallows modifiers for use with %v.Gravatar Abseil Team2022-09-20
| | | | | PiperOrigin-RevId: 475636693 Change-Id: Idb7c2b9c36ad8e59f24ff7df179a207d301d9e89
* Adds support for "%v" in absl::StrFormat and related functions for numeric ↵Gravatar Abseil Team2022-09-15
| | | | | | | types, including integer and floating point values. Users may now specify %v and have the format specifier deduced. Integer values will print according to %d specifications, unsigned values will use %u, and floating point values will use %g. Note that %v does not work for `char` due to ambiguity regarding the intended output. Please continue to use %c for `char`. PiperOrigin-RevId: 474658166 Change-Id: Iecae39263e368b27232db440535f2bf7da8d863c
* Implement correct move constructor and assignment for ↵Gravatar Andy Getzendanner2022-09-14
| | | | | | | | | absl::strings_internal::OStringStream, and mark that class final. This should be explicit per https://google.github.io/styleguide/cppguide.html#Copyable_Movable_Types, and is currently hard to infer due to multiple inheritance. PiperOrigin-RevId: 474311032 Change-Id: I72d7adcb9f7a991c19c26bc7083a4df31de5da49
* Implement Eisel-Lemire for from_chars<double>Gravatar Abseil Team2022-09-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Eisel-Lemire is a fast Atod algorithm, discussed at https://nigeltao.github.io/blog/2020/eisel-lemire.html Median of 5 runs of "time atod_manual_test pnftd/data/*.txt" user 0m1.477s # Before user 0m0.746s # After (a speed-up of 1.98x) where pnftd is https://github.com/nigeltao/parse-number-fxx-test-data "benchy --reference=srcfs --benchmark_filter='SimpleAtod' :numbers_benchmark" output (which uses deterministic but randomly generated input strings): name old cpu/op new cpu/op delta BM_SimpleAtod<absl::string_view>/10/1 388ns ± 3% 330ns ± 2% -15.06% (p=0.000 n=49+44) BM_SimpleAtod<absl::string_view>/10/2 428ns ± 3% 320ns ± 2% -25.07% (p=0.000 n=59+49) BM_SimpleAtod<absl::string_view>/10/4 431ns ± 3% 353ns ± 4% -18.04% (p=0.000 n=59+48) BM_SimpleAtod<absl::string_view>/10/8 512ns ± 3% 409ns ± 4% -20.18% (p=0.000 n=60+56) BM_SimpleAtod<const char*>/10/1 411ns ± 4% 341ns ± 3% -17.15% (p=0.000 n=51+49) BM_SimpleAtod<const char*>/10/2 431ns ± 3% 356ns ± 2% -17.44% (p=0.000 n=58+48) BM_SimpleAtod<const char*>/10/4 437ns ± 3% 378ns ± 4% -13.49% (p=0.000 n=60+50) BM_SimpleAtod<const char*>/10/8 552ns ± 2% 450ns ± 4% -18.43% (p=0.000 n=59+59) BM_SimpleAtod<std::string>/10/1 404ns ± 2% 328ns ± 2% -18.78% (p=0.000 n=48+49) BM_SimpleAtod<std::string>/10/2 438ns ± 3% 321ns ± 3% -26.81% (p=0.000 n=60+50) BM_SimpleAtod<std::string>/10/4 446ns ± 2% 354ns ± 3% -20.66% (p=0.000 n=59+50) BM_SimpleAtod<std::string>/10/8 519ns ± 2% 410ns ± 4% -21.07% (p=0.000 n=59+50) sizeof(kPower10MantissaTable) doubles from 5208 to 10416 bytes. PiperOrigin-RevId: 474174891 Change-Id: Iea6f6569419b6b55ab5978994f0adb1f4a8aafb2
* Fix "unsafe narrowing" warnings in absl, 10/n.Gravatar Abseil Team2022-09-08
| | | | | | | | | | | | | | | Addresses failures with the following, in some files: -Wshorten-64-to-32 -Wimplicit-int-conversion -Wsign-compare -Wsign-conversion -Wtautological-unsigned-zero-compare (This specific CL focuses on tests.) Bug: chromium:1292951 PiperOrigin-RevId: 473055916 Change-Id: I40cdd6c87ba9d0a5fb2db5746cff04f14ee829c2
* Fixes bug so that `%v` with modifiers doesn't compile. `%v` is not intended ↵Gravatar Abseil Team2022-09-06
| | | | | | | to work with modifiers because the meaning of modifiers is type-dependent and `%v` is intended to be used in situations where the type is not important. Please continue using if `%s` if you require format modifiers. PiperOrigin-RevId: 472534916 Change-Id: I5838761b2b40cbc4344077f23d44b1e634e5bae3
* Refactors checker.h and replaces recursive functions with iterative ↵Gravatar Abseil Team2022-09-01
| | | | | | | functions for readability purposes. PiperOrigin-RevId: 471622216 Change-Id: Ic28ed8e26d5085ccf20290d1b9c7a5e9bc1f0fde
* Refactors checker.h to use if statements instead of ternary operators for ↵Gravatar Abseil Team2022-09-01
| | | | | | | better readability. PiperOrigin-RevId: 471621696 Change-Id: I603e5707d896deef3a015c70ceac9778e360f72f
* Adds support for "%v" in absl::StrFormat and related functions for ↵Gravatar Abseil Team2022-08-31
| | | | | | | string-like types (support for other builtin types will follow in future changes). Rather than specifying %s for strings, users may specify %v and have the format specifier deduced. Notably, %v does not work for `const char*` because we cannot be certain if %s or %p was intended (nor can we be certain if the `const char*` was properly null-terminated). If you have a `const char*` you know is null-terminated and would like to work with %v, please wrap it in a `string_view` before using it. PiperOrigin-RevId: 471321055 Change-Id: Ifbb50082d301baecc7edc277975f12e7ad3ecc8a
* Fixed header guards to match style guide conventions.Gravatar Abseil Team2022-08-31
| | | | | PiperOrigin-RevId: 471292183 Change-Id: Ic124d671dd3b0ae819f741885abb046cbf7e1add
* Fix "unsafe narrowing" warnings in absl, 6/n.Gravatar Abseil Team2022-08-29
| | | | | | | | | | | | | | | Addresses failures with the following, in some files: -Wshorten-64-to-32 -Wimplicit-int-conversion -Wsign-compare -Wsign-conversion -Wtautological-unsigned-zero-compare (This specific CL focuses on .cc files in strings/internal/.) Bug: chromium:1292951 PiperOrigin-RevId: 470810568 Change-Id: Ibd316a7e62cc43cb198ba22daed565c9573ce235