MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / to_string

Function to_string

source/to_string.cpp:21–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19namespace spvtools {
20
21std::string to_string(uint32_t n) {
22 // This implementation avoids using standard library features that access
23 // the locale. Using the locale requires taking a mutex which causes
24 // annoying serialization.
25
26 constexpr int max_digits = 10; // max uint has 10 digits
27 // Contains the resulting digits, with least significant digit in the last
28 // entry.
29 char buf[max_digits];
30 int write_index = max_digits - 1;
31 if (n == 0) {
32 buf[write_index] = '0';
33 } else {
34 while (n > 0) {
35 int units = n % 10;
36 buf[write_index--] = "0123456789"[units];
37 n = (n - units) / 10;
38 }
39 write_index++;
40 }
41 assert(write_index >= 0);
42 return std::string(buf + write_index, max_digits - write_index);
43}
44} // namespace spvtools

Callers 8

GetTrivialNameMapperFunction · 0.70
NameForIdMethod · 0.70
SaveNameMethod · 0.70
ParseInstructionMethod · 0.70
NameForEnumOperandMethod · 0.70
ValidateSetMeshOutputsFunction · 0.50
ValidateArrayedF32VecMethod · 0.50
IdAsStringMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected