@@ -65,33 +65,6 @@ champagne_lemire_really_inline std::array<char, 2> get_one_digit_with_dot(uint32
6565 return digit_table[value];
6666}
6767
68- champagne_lemire_really_inline std::array<char , 3 > get_two_digits_with_dot (uint32_t value) {
69- constexpr static std::array<std::array<char , 3 >, 100 > hundreds_digit_table =
70- []() {
71- std::array<std::array<char , 3 >, 100 > table{};
72- for (int i = 0 ; i < 100 ; ++i) {
73- table[i] = {static_cast <char >((i / 10 ) % 10 + ' 0' ), ' .' ,
74- static_cast <char >((i % 10 ) + ' 0' )};
75- }
76- return table;
77- }();
78- return hundreds_digit_table[value];
79- }
80-
81-
82-
83- champagne_lemire_really_inline std::array<char , 4 > get_two_digits_with_dot_with_one_pad (uint32_t value) {
84- constexpr static std::array<std::array<char , 4 >, 100 > hundreds_digit_table =
85- []() {
86- std::array<std::array<char , 4 >, 100 > table{};
87- for (int i = 0 ; i < 100 ; ++i) {
88- table[i] = {static_cast <char >((i / 10 ) % 10 + ' 0' ), ' .' ,
89- static_cast <char >((i % 10 ) + ' 0' ), ' 0' }; // extra pad
90- }
91- return table;
92- }();
93- return hundreds_digit_table[value];
94- }
9568
9669champagne_lemire_really_inline std::array<char , 2 > get_two_digits_v (uint32_t value) {
9770 constexpr static std::array<std::array<char , 2 >, 256 > hundreds_digit_table =
@@ -121,45 +94,6 @@ champagne_lemire_really_inline std::array<char, 2> get_two_digits(uint32_t value
12194 return hundreds_digit_table[value];
12295}
12396
124- // We stop at 309 because that is the upper bound for the exponent in a double
125- champagne_lemire_really_inline std::array<char , 3 > get_three_digits (uint32_t value) {
126- constexpr static std::array<std::array<char , 3 >, 309 > digit_table =
127- []() {
128- std::array<std::array<char , 3 >, 309 > table;
129- for (int i = 0 ; i < 309 ; ++i) {
130- table[i][0 ] = (i / 100 ) + ' 0' ;
131- // Calculate the tens digit
132- table[i][1 ] = ((i / 10 ) % 10 ) + ' 0' ;
133- // Calculate the units digit
134- table[i][2 ] = (i % 10 ) + ' 0' ;
135- }
136- return table;
137- }();
138- return digit_table[value];
139- }
140-
141- champagne_lemire_really_inline void write_one_digit_with_dot (char *buffer, uint32_t value) {
142- std::memcpy (buffer, get_one_digit_with_dot (value).data (), 2 );
143- }
144-
145- champagne_lemire_really_inline void write_two_digits_with_dot (char *buffer, uint32_t value) {
146- std::memcpy (buffer, get_two_digits_with_dot (value).data (), 3 );
147- }
148-
149- // writes two digits, a dot, and a padding zero, why the padding zero? because
150- // it is faster to copy four bytes than three bytes on most architectures.
151- champagne_lemire_really_inline void write_two_digits_with_dot_with_one_pad (char *buffer, uint32_t value) {
152- std::memcpy (buffer, get_two_digits_with_dot_with_one_pad (value).data (), 4 );
153- }
154-
155- champagne_lemire_really_inline void write_two_digits (char *buffer, uint32_t value) {
156- std::memcpy (buffer, get_two_digits (value).data (), 2 );
157- }
158-
159- champagne_lemire_really_inline void write_two_digits_v (char *buffer, uint32_t value) {
160- std::memcpy (buffer, get_two_digits_v (value).data (), 2 );
161- }
162-
16397champagne_lemire_really_inline void write_three_digits (char *buffer, uint32_t value) {
16498 std::memcpy (buffer, get_three_digits (value).data (), 3 );
16599}
0 commit comments