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
| Name |
Last commit
|
Last Update |
|---|---|---|
| .. | ||
| internal | Loading commit data... | |
| BUILD.bazel | Loading commit data... | |
| CMakeLists.txt | Loading commit data... | |
| ascii.cc | Loading commit data... | |
| ascii.h | Loading commit data... | |
| ascii_benchmark.cc | Loading commit data... | |
| ascii_test.cc | Loading commit data... | |
| atod_manual_test.cc | Loading commit data... | |
| char_formatting_test.cc | Loading commit data... | |
| charconv.cc | Loading commit data... | |
| charconv.h | Loading commit data... | |
| charconv_benchmark.cc | Loading commit data... | |
| charconv_test.cc | Loading commit data... | |
| charset.h | Loading commit data... | |
| charset_benchmark.cc | Loading commit data... | |
| charset_test.cc | Loading commit data... | |
| cord.cc | Loading commit data... | |
| cord.h | Loading commit data... | |
| cord_analysis.cc | Loading commit data... | |
| cord_analysis.h | Loading commit data... | |
| cord_buffer.cc | Loading commit data... | |
| cord_buffer.h | Loading commit data... | |
| cord_buffer_test.cc | Loading commit data... | |
| cord_test.cc | Loading commit data... | |
| cord_test_helpers.h | Loading commit data... | |
| cordz_test.cc | Loading commit data... | |
| cordz_test_helpers.h | Loading commit data... | |
| escaping.cc | Loading commit data... | |
| escaping.h | Loading commit data... | |
| escaping_benchmark.cc | Loading commit data... | |
| escaping_test.cc | Loading commit data... | |
| has_absl_stringify.h | Loading commit data... | |
| has_absl_stringify_test.cc | Loading commit data... | |
| has_ostream_operator.h | Loading commit data... | |
| has_ostream_operator_test.cc | Loading commit data... | |
| match.cc | Loading commit data... | |
| match.h | Loading commit data... | |
| match_test.cc | Loading commit data... | |
| numbers.cc | Loading commit data... | |
| numbers.h | Loading commit data... | |
| numbers_benchmark.cc | Loading commit data... | |
| numbers_test.cc | Loading commit data... | |
| str_cat.cc | Loading commit data... | |
| str_cat.h | Loading commit data... | |
| str_cat_benchmark.cc | Loading commit data... | |
| str_cat_test.cc | Loading commit data... | |
| str_format.h | Loading commit data... | |
| str_format_test.cc | Loading commit data... | |
| str_join.h | Loading commit data... | |
| str_join_benchmark.cc | Loading commit data... | |
| str_join_test.cc | Loading commit data... | |
| str_replace.cc | Loading commit data... | |
| str_replace.h | Loading commit data... | |
| str_replace_benchmark.cc | Loading commit data... | |
| str_replace_test.cc | Loading commit data... | |
| str_split.cc | Loading commit data... | |
| str_split.h | Loading commit data... | |
| str_split_benchmark.cc | Loading commit data... | |
| str_split_test.cc | Loading commit data... | |
| string_view.cc | Loading commit data... | |
| string_view.h | Loading commit data... | |
| string_view_benchmark.cc | Loading commit data... | |
| string_view_test.cc | Loading commit data... | |
| strip.h | Loading commit data... | |
| strip_test.cc | Loading commit data... | |
| substitute.cc | Loading commit data... | |
| substitute.h | Loading commit data... | |
| substitute_test.cc | Loading commit data... |