diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2021-03-10 16:23:20 +0000 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2021-03-10 16:23:20 +0000 |
commit | 89bd4269018fa5a36a15eac8d2c3f99674d18b2d (patch) | |
tree | c7b02b7de13f3c1ac6a869e15311d7e5e5de4096 /indra/llui/lluiusage.cpp | |
parent | dd89dec893411c22d4916de14593a56f87d3a284 (diff) |
SL-14862 - use nested LLSD for widget info, condensed to the two leaf-most elements of the path. Simplified floater logging.
Diffstat (limited to 'indra/llui/lluiusage.cpp')
-rw-r--r-- | indra/llui/lluiusage.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/indra/llui/lluiusage.cpp b/indra/llui/lluiusage.cpp index 99de4ff78a..824c59730b 100644 --- a/indra/llui/lluiusage.cpp +++ b/indra/llui/lluiusage.cpp @@ -26,6 +26,7 @@ #include "linden_common.h" #include "lluiusage.h" +#include <boost/algorithm/string.hpp> LLUIUsage::LLUIUsage() { @@ -41,9 +42,39 @@ std::string LLUIUsage::sanitized(const std::string& s) // ViewerStats db doesn't like "." in keys std::string result(s); std::replace(result.begin(), result.end(), '.', '_'); + std::replace(result.begin(), result.end(), ' ', '_'); return result; } +void LLUIUsage::setLLSDNested(LLSD& sd, const std::string& path, S32 max_elts, S32 val) const +{ + std::vector<std::string> fields; + boost::split(fields, path, boost::is_any_of("/")); + auto first_pos = std::max(fields.begin(), fields.end() - max_elts); + auto end_pos = fields.end(); + std::vector<std::string> last_fields(first_pos,end_pos); + + // Code below is just to accomplish the equivalent of + // sd[last_fields[0]][last_fields[1]] = LLSD::Integer(val); + // for an arbitrary number of fields. + LLSD* fsd = &sd; + for (auto it=last_fields.begin(); it!=last_fields.end(); ++it) + { + if (it == last_fields.end()-1) + { + (*fsd)[*it] = LLSD::Integer(val); + } + else + { + if (!(*fsd)[*it].isMap()) + { + (*fsd)[*it] = LLSD::emptyMap(); + } + fsd = &(*fsd)[*it]; + } + } +} + void LLUIUsage::logFloater(const std::string& floater) { mFloaterCounts[sanitized(floater)]++; @@ -75,7 +106,7 @@ LLSD LLUIUsage::asLLSD() const } for (auto const& it : mWidgetCounts) { - result["widgets"][it.first] = LLSD::Integer(it.second); + setLLSDNested(result["widgets"], it.first, 2, it.second); } return result; } |