MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / insert_commas

Function insert_commas

common/alog.cpp:158–181  ·  view source on GitHub ↗

static inline void insert_comma(char* begin, char*& ptr, uint64_t width, char padding)

Source from the content-addressed store, hash-verified

156
157//static inline void insert_comma(char* begin, char*& ptr, uint64_t width, char padding)
158static void insert_commas(char*& digits_end, uint64_t ndigits)
159{
160 if (ndigits <= 0) return;
161 auto ncomma = (ndigits - 1) / 3;
162 auto psrc = digits_end;
163 digits_end += ncomma;
164 auto pdest = digits_end;
165
166 struct temp
167 {
168 char data[4];
169 temp(const char* psrc)
170 {
171 *(uint32_t*)data = *(uint32_t*)(psrc-1);
172 data[0] = ',';
173 }
174 };
175
176 while (pdest != psrc)
177 {
178 psrc -= 3; pdest -= 4;
179 *(temp*)pdest = temp(psrc);
180 }
181}
182
183void LogFormatter::put_integer_dec(ALogBuffer& buf, ALogInteger x)
184{

Callers 1

put_integer_decMethod · 0.85

Calls 1

tempClass · 0.85

Tested by

no test coverage detected