4 ms·
For languages like C and C++, the idiomatic way to get the first optimization mentioned is to use formatting strings. Instead of splitting these two calls into
by mgraczyk 4y ago
For languages like C and C++, the idiomatic way to get the first optimization mentioned is to use formatting strings.
Instead of splitting these two calls into four:
printf("Good day professor Jones");
printf("Good day professor Jane");
-->
printf("Good day professor ");
printf("Jones");
printf("Good day professor ");
printf("Jane");
You should use formatting strings
printf("Good day professor %s", "Jones");
printf("Good day professor %s", "Jane");
You'll get the same interning optimization, although you may get an extra "malloc" in printf which two calls would avoid.