summaryrefslogtreecommitdiff
path: root/absl/strings
Commit message (Collapse)AuthorAge
...
| * 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
* Fix "unsafe narrowing" warnings in absl, 5/n.Gravatar Abseil Team2022-08-17
| | | | | | | | | | | | | | | 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: 468215101 Change-Id: I07fa487bcf2cf62d403489c3be7a5997cdef8987
* Fix "unsafe narrowing" warnings in absl, 4/n.Gravatar Abseil Team2022-08-17
| | | | | | | | | | | | | | | 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/, except /internal/.) Bug: chromium:1292951 PiperOrigin-RevId: 468205572 Change-Id: Ifce3f1a7a4b2b2c359bf7700a11279bebfef8a15
* Add more SimpleAtod / SimpleAtof test coverageGravatar Abseil Team2022-08-04
| | | | | PiperOrigin-RevId: 465451170 Change-Id: I5fd161b1ef156d60d7f9a6ecf493bcf802d581e8
* Revert change "Fix "unsafe narrowing" warnings in absl, 4/n.".Gravatar Thomas Köppe2022-08-04
| | | | | | | The change breaks existing code by changing the return type of absl::bit_width. PiperOrigin-RevId: 465295951 Change-Id: Id4ce7c2ac3699ce22aa2b4851a949f9e0104a3d7
* Fix "unsafe narrowing" warnings in absl, 4/n.Gravatar Abseil Team2022-08-04
| | | | | | | | | | | | | | | 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/, except /internal/.) Bug: chromium:1292951 PiperOrigin-RevId: 465285043 Change-Id: I37e9d1b4c4e9aa655b720da1467927af2aba995e
* Fix "unsafe narrowing" warnings in absl, 1/n.Gravatar Abseil Team2022-07-28
| | | | | | | | | | | | | | | 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 .h and win32 .inc files.) Bug: chromium:1292951 PiperOrigin-RevId: 463835431 Change-Id: If8e5f7f651d5cd96035e23e4623bdb08a7fedabe
* Use HTTPS RFC URLs, which work regardless of the browser's locale.Gravatar Abseil Team2022-07-18
| | | | | PiperOrigin-RevId: 461737981 Change-Id: Iefb1d703725f0a258b5ee315c55277b261b75418
* Internal Cleanup: removing unused internal function declaration.Gravatar Martijn Vels2022-07-18
| | | | | PiperOrigin-RevId: 461616203 Change-Id: I4cf2e0738451a0471bb8341d9af003d271331fab
* Add GetCustomAppendBuffer method to absl::CordGravatar Martijn Vels2022-07-15
| | | | | | | | | The Cord::GetCustomAppendBuffer() method provides the same functionality as Cord::GetAppendBuffer(), except that callers can specify a custom block size/limit if the method returns a newly allocated buffer. In other words: Cord::GetAppendBuffer() defaults to CordBuffer::CreateWithDefaultLimit(), Cord::GetCustomAppendBuffer() defaults to CordBuffer::CreateWithCustomLimit(). PiperOrigin-RevId: 461231989 Change-Id: I5c03f31139d9b068feee1bea76d59e1c5e30ef07
* string_view: conditional constexpr is no longer needed for C++14Gravatar Derek Mauro2022-07-12
| | | | | PiperOrigin-RevId: 460407142 Change-Id: I9501d2e79cf8c20c5261ab0169bd4bbc3b02980c
* Minor wording fix in the comment for ConsumeSuffix()Gravatar Abseil Team2022-06-10
| | | | | PiperOrigin-RevId: 454305599 Change-Id: I528dfe0223280c379d8791373dc2871ad5812f63
* Fix several typos in comments.Gravatar Abseil Team2022-06-10
| | | | | PiperOrigin-RevId: 454185620 Change-Id: Ifdff33cec4bdd63f160a8d3c18f959ac2a3b6f25
* Fix C++17 constexpr storage deprecation warningsGravatar Derek Mauro2022-06-09
| | | | | | | | | | | | | | | | | | | This change introduces the symbol ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL to guard redundant declarations of static constexpr data members that are needed prior to C++17. This change also introduces the symbol ABSL_INTERNAL_CPLUSPLUS_LANG, which is supposed to be set to the same value as __cplusplus, except it uses _MSVC_LANG on MSVC so that the value is correct on MSVC. Neither of these new symbols should be used outside of Abseil. Fixes #1191 PiperOrigin-RevId: 453923908 Change-Id: I1316c52c19fa0c168b93cced0c817e4cb7c9c862
* Obey ABSL_DEFAULT_LINKOPTS for all cc_library targetsGravatar Jeremy Nimmer2022-06-06
| | | | | | | A few targets were missing `linkopts = ...` and so were not obeying the project-wide default settings. Omit any changes to cctz for now, because it's vendored from another project.
* Add ABSL_HARDENING_ASSERTs to CordBuffer::SetLength() andGravatar Derek Mauro2022-06-06
| | | | | | | CordBuffer::IncreaseLengthBy() PiperOrigin-RevId: 453243686 Change-Id: If109da6be651006d4d9820bcc10eddfb56deaea2
* Release absl::CordBufferGravatar Derek Mauro2022-06-06
| | | | | | | | | absl::CordBuffer holds data for eventual inclusion within an existing absl::Cord. CordBuffers are useful for building large Cords that may require custom allocation of its associated memory, a pattern that is common in zero-copy APIs. PiperOrigin-RevId: 453212229 Change-Id: I6a8adc3a8d206691cb1b0001a9161e5080dd1c5f
* Improve the compiler error by removing some noise from it.Gravatar Samuel Benzaquen2022-06-03
| | | | | | | The "deleted" overload error is useless to users. By passing some dummy string to the base class constructor we use a valid constructor and remove the unintended use of the deleted default constructor. PiperOrigin-RevId: 452826509 Change-Id: I5430a373c8e7e3a13336d2c42899e0e59444620b
* Merge pull request #1187 from trofi:fix-gcc-13-buildGravatar Copybara-Service2022-05-31
|\ | | | | | | | | PiperOrigin-RevId: 452110436 Change-Id: I3cb870935932c7e2895c8a7f019f375ad707ee77
| * absl/strings/internal/str_format/extension.h: add missing <stdint.h> includeGravatar Sergei Trofimovich2022-05-27
|/ | | | | | | | | Without the change absl-cpp build fails on this week's gcc-13 snapshot as: /build/abseil-cpp/absl/strings/internal/str_format/extension.h:34:33: error: found ':' in nested-name-specifier, expected '::' 34 | enum class FormatConversionChar : uint8_t; | ^ | ::
* Fix typos.Gravatar Abseil Team2022-05-27
| | | | | PiperOrigin-RevId: 451434783 Change-Id: I572e77a67e18e8dd530bf0347c76863c9bb1946f
* Cord: workaround a GCC 12.1 bug that triggers a spurious warningGravatar Derek Mauro2022-05-20
| | | | | | | | | | | | | See the GCC bug report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105585 and Abseil bug report https://github.com/abseil/abseil-cpp/issues/1175 Fixes #1175 PiperOrigin-RevId: 450083136 Change-Id: I207aaffaec9166b335065dd6ef148a721b94048e
* Use NullSafeStringView for const char* args to absl::StrCat, treating null ↵Gravatar Dino Radakovic2022-05-17
| | | | | | | | | pointers as "" Fixes #1167 PiperOrigin-RevId: 449328725 Change-Id: I813785db77b94efa49eeeff4c93449334c380935
* Improve compiler errors for mismatched ParsedFormat inputs.Gravatar Samuel Benzaquen2022-05-13
| | | | | PiperOrigin-RevId: 448582508 Change-Id: I67fbff5f42a083e093ea2c20749e073ca03feb0b
* Fix an msan warning in cord_ringbuffer_testGravatar Benjamin Barenblat2022-05-12
| | | | | | | | | Stop the absl::Cord destructor from running on the constinit cord in CordTest.ConstinitConstructor. This allows inspecting the cord at any point while the test is exiting, which is important for the semantics of the test. PiperOrigin-RevId: 448327386 Change-Id: Icef9faa2b63f1f0ae60b3430dcf6184f5dead885
* Document that Consume(Prefix|Suffix)() don't modify the input on failureGravatar Abseil Team2022-05-11
| | | | | PiperOrigin-RevId: 448075898 Change-Id: Ia4047f833bf27c62752b41f4ba65ab3be88a0181