Browse Source

DebugTools: can do the string joining better, actually.

pull/680/head
Vladimír Vondruš 11 months ago
parent
commit
565cc7bdab
  1. 14
      src/Magnum/DebugTools/FrameProfiler.cpp

14
src/Magnum/DebugTools/FrameProfiler.cpp

@ -714,17 +714,15 @@ DebugTools::FrameProfilerGL::Value ConfigurationValue<DebugTools::FrameProfilerG
Containers::String ConfigurationValue<DebugTools::FrameProfilerGL::Values>::toString(const DebugTools::FrameProfilerGL::Values value, ConfigurationValueFlags) { Containers::String ConfigurationValue<DebugTools::FrameProfilerGL::Values>::toString(const DebugTools::FrameProfilerGL::Values value, ConfigurationValueFlags) {
Containers::String out; Containers::String out;
/* Create an array of strings where each is non-empty only if given bit is
set and then join them together to have just one allocation */
const char* names[Containers::arraySize(DebugTools::FrameProfilerGLValueNames)]{};
for(std::size_t i = 0; i != Containers::arraySize(DebugTools::FrameProfilerGLValueNames); ++i) { for(std::size_t i = 0; i != Containers::arraySize(DebugTools::FrameProfilerGLValueNames); ++i) {
const auto bit = DebugTools::FrameProfilerGL::Value(1 << i); if(value & DebugTools::FrameProfilerGL::Value(1 << i))
if(value & bit) { names[i] = DebugTools::FrameProfilerGLValueNames[i];
/** @todo ugh, one allocation per bit, fix when growable String is
a thing ... or maybe some "get set bits" utility and then call
join just once? */
out = " "_s.joinWithoutEmptyParts({out, DebugTools::FrameProfilerGLValueNames[i]});
}
} }
return out; return " "_s.joinWithoutEmptyParts(names);
} }
DebugTools::FrameProfilerGL::Values ConfigurationValue<DebugTools::FrameProfilerGL::Values>::fromString(const Containers::StringView value, ConfigurationValueFlags) { DebugTools::FrameProfilerGL::Values ConfigurationValue<DebugTools::FrameProfilerGL::Values>::fromString(const Containers::StringView value, ConfigurationValueFlags) {

Loading…
Cancel
Save