Browse Source

use a smaller buffer

fmt::memory_buffer uses 500 bytes by default, go back to a 12 byte char array to avoid all the cruft
pull/4857/head
ephphatha 4 years ago committed by Gleb Mazovetskiy
parent
commit
0f1ac758d8
  1. 10
      Source/engine/render/scrollrt.cpp

10
Source/engine/render/scrollrt.cpp

@ -1321,7 +1321,7 @@ void DrawView(const Surface &out, Point startPosition)
void DrawFPS(const Surface &out)
{
static int framesSinceLastUpdate = 0;
static fmt::memory_buffer buf {};
static string_view formatted {};
if (!frameflag || !gbActive) {
return;
@ -1334,10 +1334,12 @@ void DrawFPS(const Surface &out)
lastFpsUpdateInMs = runtimeInMs;
int framerate = 1000 * framesSinceLastUpdate / msSinceLastUpdate;
framesSinceLastUpdate = 0;
buf.clear();
fmt::format_to(std::back_inserter(buf), FMT_COMPILE("{} FPS"), framerate);
static char buf[12] {};
const char *end = fmt::format_to_n(buf, sizeof(buf), FMT_COMPILE("{} FPS"), framerate).out;
formatted = { buf, static_cast<string_view::size_type>(end - buf) };
};
DrawString(out, { buf.data(), buf.size() }, Point { 8, 68 }, UiFlags::ColorRed);
DrawString(out, formatted, Point { 8, 68 }, UiFlags::ColorRed);
}
/**

Loading…
Cancel
Save