summaryrefslogtreecommitdiff
path: root/src/mongo/util/itoa.h
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2019-07-24 16:29:42 -0400
committerBilly Donahue <billy.donahue@mongodb.com>2019-07-29 10:58:53 -0400
commitdae371c478e1a828ac911096d85f94be8e936ef9 (patch)
tree24eb584ce9c27684583da4639803fc1a6019d14a /src/mongo/util/itoa.h
parent2ae4fd3e580c90ecfca524d02b9a484f671768f0 (diff)
downloadmongo-dae371c478e1a828ac911096d85f94be8e936ef9.tar.gz
SERVER-42034 Optimize ItoA
(~13% faster, remove the 1kLoC static table) Reverts commit 7c9edfd4b931f3d3208142b411010b6b4afee21e. Python-generate table-emitting macro (compiler workaround).
Diffstat (limited to 'src/mongo/util/itoa.h')
-rw-r--r--src/mongo/util/itoa.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/mongo/util/itoa.h b/src/mongo/util/itoa.h
index 37451847a95..878bd62d3b6 100644
--- a/src/mongo/util/itoa.h
+++ b/src/mongo/util/itoa.h
@@ -41,23 +41,20 @@ namespace mongo {
* and only really should be used in hot code paths.
*/
class ItoA {
- ItoA(const ItoA&) = delete;
- ItoA& operator=(const ItoA&) = delete;
-
public:
- static constexpr size_t kBufSize = std::numeric_limits<uint64_t>::digits10 //
- + 1 // digits10 is 1 less than the maximum number of digits.
- + 1; // NUL byte.
+ // digits10 is 1 less than the maximum number of digits.
+ static constexpr size_t kBufSize = std::numeric_limits<std::uint64_t>::digits10 + 1;
explicit ItoA(std::uint64_t i);
+ ItoA(const ItoA&) = delete;
+ ItoA& operator=(const ItoA&) = delete;
- operator StringData() {
- return {_str, _len};
+ operator StringData() const {
+ return _str;
}
private:
- const char* _str{nullptr};
- std::size_t _len{0};
+ StringData _str;
char _buf[kBufSize];
};