From e01b8b983dea56e22800bcdf64cb7b4c77c4b70a Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Tue, 29 Sep 2020 09:38:03 -0400 Subject: [PATCH] Start changing a few llformat(vsnprtinf wrapper) over to absl::StrFormat --- indra/llcommon/llerror.cpp | 5 +++-- indra/llcommon/llsdparam.cpp | 4 +++- indra/llcommon/llstring.cpp | 14 ++++++++------ indra/llcommon/lltimer.cpp | 4 +++- indra/llcommon/lluuid.cpp | 4 +++- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 723493a4455..465cf7d40aa 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -47,6 +47,7 @@ #include <string_view> #include "string.h" #include <absl/container/flat_hash_map.h> +#include <absl/strings/str_format.h> #include "llapp.h" #include "llapr.h" @@ -647,7 +648,7 @@ namespace LLError default: mLevelString = "XXX"; break; }; - mLocationString = llformat("%s(%d)", abbreviateFile(mFile).c_str(), mLine); + mLocationString = absl::StrFormat("%s(%d)", abbreviateFile(mFile), mLine); #if LL_WINDOWS // DevStudio: __FUNCTION__ already includes the full class name #else @@ -1397,7 +1398,7 @@ namespace LLError return; } - if(strlen(out->str().c_str()) < 128) + if (out->str().length() < 128) { strcpy(message, out->str().c_str()); } diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index 6a824e2faf2..ef845e157b3 100644 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -32,6 +32,8 @@ #include "llsdutil.h" #include "boost/bind.hpp" +#include <absl/strings/str_format.h> + static LLInitParam::Parser::parser_read_func_map_t sReadFuncs; static LLInitParam::Parser::parser_write_func_map_t sWriteFuncs; static LLInitParam::Parser::parser_inspect_func_map_t sInspectFuncs; @@ -119,7 +121,7 @@ void LLParamSDParser::writeSDImpl(LLSD& sd, const LLInitParam::BaseBlock& block, it != mNameStack.end(); ++it) { - full_name += llformat("[%s]", it->first.c_str()); + absl::StrAppendFormat(&full_name, "[%s]", it->first); } return full_name; diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index fea9cb10b80..686aa0a1b1b 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -37,6 +37,8 @@ #include <winnls.h> // for WideCharToMultiByte #endif +#include <absl/strings/str_format.h> + LLTrace::BlockTimerStatHandle FT_STRING_FORMAT("String Format"); @@ -1058,19 +1060,19 @@ std::string LLStringOps::getReadableNumber(F64 num) { if (fabs(num)>=1e9) { - return llformat("%.2lfB", num / 1e9); + return absl::StrFormat("%.2lfB", num / 1e9); } else if (fabs(num)>=1e6) { - return llformat("%.2lfM", num / 1e6); + return absl::StrFormat("%.2lfM", num / 1e6); } else if (fabs(num)>=1e3) { - return llformat("%.2lfK", num / 1e3); + return absl::StrFormat("%.2lfK", num / 1e3); } else { - return llformat("%.2lf", num); + return absl::StrFormat("%.2lf", num); } } @@ -1376,14 +1378,14 @@ bool LLStringUtil::formatDatetime(std::string& replacement, std::string token, { struct tm * gmt = gmtime (&loc_seconds); LLStringUtil::format_map_t args; - args["[MDAY]"] = llformat ("%d", gmt->tm_mday); + args["[MDAY]"] = absl::StrFormat("%d", gmt->tm_mday); replacement = LLStringOps::sDayFormat; LLStringUtil::format(replacement, args); } else if (code == "%-d") { struct tm * gmt = gmtime (&loc_seconds); - replacement = llformat ("%d", gmt->tm_mday); // day of the month without leading zero + replacement = absl::StrFormat("%d", gmt->tm_mday); // day of the month without leading zero } else if( !LLStringOps::sAM.empty() && !LLStringOps::sPM.empty() && code == "%p" ) { diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 6909cca9172..43a4cc2dd08 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -39,6 +39,8 @@ # error "architecture not supported" #endif +#include <absl/strings/str_format.h> + #include <chrono> #include <thread> @@ -467,7 +469,7 @@ void microsecondsToTimecodeString(U64MicrosecondsImplicit current_time, std::str subframes = current_time / (U64)42; subframes %= 100; - tcstring = llformat("%3.3d:%2.2d:%2.2d:%2.2d.%2.2d",(int)hours,(int)minutes,(int)seconds,(int)frames,(int)subframes); + tcstring = absl::StrFormat("%3.3d:%2.2d:%2.2d:%2.2d.%2.2d", hours, minutes, seconds, frames, subframes); } diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index fa66adc7b8f..4e349514c34 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -45,6 +45,8 @@ #include "llthread.h" #include "llmutex.h" +#include <absl/strings/str_format.h> + const LLUUID LLUUID::null; const LLTransactionID LLTransactionID::tnull; @@ -154,7 +156,7 @@ U32 janky_fast_random_seeded_bytes(U32 seed, U32 val) // Common to all UUID implementations void LLUUID::toString(std::string& out) const { - out = llformat( + out = absl::StrFormat( "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", (U8)(mData[0]), (U8)(mData[1]), -- GitLab