[libcxx-commits] [PATCH] D59178: [libc++] Speedup to_string and to_wstring for integers using stack buffer and SSO
Vlad Tsyrklevich via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 6 00:48:18 PDT 2019
vlad.tsyrklevich added a comment.
I tested the following change and verified that it works for the numeric example above, but don't have time to write a test and monitor for build failures so I'm going to revert this change for now. Leaving it here for whoever wants to pick it up:
--- a/libcxx/src/charconv.cpp
+++ b/libcxx/src/charconv.cpp
@@ -176,22 +176,39 @@ __u64toa(uint64_t value, char* buffer)
const uint32_t b0 = v0 / 10000;
const uint32_t c0 = v0 % 10000;
- if (v0 < 1000000)
+ if (b0)
{
- if (v0 < 100000)
- buffer = append1(buffer, b0);
+ if (b0 < 100)
+ {
+ if (b0 < 10)
+ buffer = append1(buffer, b0);
+ else
+ buffer = append2(buffer, b0);
+ }
+ else
+ {
+ if (b0 < 1000)
+ buffer = append3(buffer, b0);
+ else
+ buffer = append4(buffer, b0);
+ }
+ }
+
+ if (c0 < 100)
+ {
+ if (c0 < 10)
+ buffer = append1(buffer, c0);
else
- buffer = append2(buffer, b0);
+ buffer = append2(buffer, c0);
}
else
{
- if (v0 < 10000000)
- buffer = append3(buffer, b0);
+ if (c0 < 1000)
+ buffer = append3(buffer, c0);
else
- buffer = append4(buffer, b0);
+ buffer = append4(buffer, c0);
}
- buffer = append4(buffer, c0);
buffer = append4(buffer, v1 / 10000);
buffer = append4(buffer, v1 % 10000);
}
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59178/new/
https://reviews.llvm.org/D59178
More information about the libcxx-commits
mailing list