| 30 | |
| 31 | namespace { |
| 32 | std::string scaled(double n, const char* unit) |
| 33 | { |
| 34 | char buf[32]; |
| 35 | // One decimal below 10 of a unit, none above: "1.4 MB" is worth the |
| 36 | // digit, "947.3 MB" is noise in a figure that moves every frame. |
| 37 | if (n < 10.0) { |
| 38 | snprintf(buf, sizeof buf, "%.1f %s", n, unit); |
| 39 | } |
| 40 | else { |
| 41 | snprintf(buf, sizeof buf, "%d %s", (int)(n + 0.5), unit); |
| 42 | } |
| 43 | return buf; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | namespace ScriptBar { |