return loadavg[0];
}
#endif // _WIN32
-double GetLoadAverage()
-{
-#ifdef _WIN32
- return GetLoadAverage_win32();
-#else
- return GetLoadAverage_unix();
-#endif // _WIN32
-}
-
-string ElideMiddle(const string& str, size_t width)
-{
+
++string ElideMiddle(const string& str, size_t width) {
+ const int kMargin = 3; // Space for "...".
+ string result = str;
+ if (result.size() + kMargin > width) {
+ int elide_size = (width - kMargin) / 2;
+ result = result.substr(0, elide_size)
+ + "..."
+ + result.substr(result.size() - elide_size, elide_size);
+ }
+ return result;
+ }