From 22a739446d8c84b0e4e9a7fa8379bfc68cb19a4e Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Tue, 29 Sep 2020 03:43:10 -0400 Subject: [PATCH] Various cleanups to container usage and change to emplace --- indra/llcommon/lldependencies.h | 2 +- indra/llcommon/lldictionary.h | 6 +++--- indra/llcommon/llfixedbuffer.cpp | 2 +- indra/llcommon/llstacktrace.cpp | 4 ++-- indra/llcommon/llstreamqueue.h | 2 +- indra/llcommon/llstring.cpp | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/indra/llcommon/lldependencies.h b/indra/llcommon/lldependencies.h index 6b6a9500e0a..6bc5331dc24 100644 --- a/indra/llcommon/lldependencies.h +++ b/indra/llcommon/lldependencies.h @@ -583,7 +583,7 @@ class LLDependencies: public LLDependenciesBase if (found != non_const_this->mNodes.end()) { // Make an iterator of appropriate type. - mCache.push_back(iterator(found, value_extract)); + mCache.emplace_back(iterator(found, value_extract)); } } } diff --git a/indra/llcommon/lldictionary.h b/indra/llcommon/lldictionary.h index a4dbe43f417..7dd889a62b4 100644 --- a/indra/llcommon/lldictionary.h +++ b/indra/llcommon/lldictionary.h @@ -63,9 +63,9 @@ class LLDictionary : public std::map<Index, Entry *> } const Index lookup(const std::string_view name) const { - for (const_iterator_t dictionary_iter = map_t::begin(); - dictionary_iter != map_t::end(); - dictionary_iter++) + for (const_iterator_t dictionary_iter = map_t::begin(), end_iter = map_t::end(); + dictionary_iter != end_iter; + ++dictionary_iter) { const Entry *entry = dictionary_iter->second; if (entry->mName == name) diff --git a/indra/llcommon/llfixedbuffer.cpp b/indra/llcommon/llfixedbuffer.cpp index bd4db8be845..bf2f15d13f9 100644 --- a/indra/llcommon/llfixedbuffer.cpp +++ b/indra/llcommon/llfixedbuffer.cpp @@ -71,7 +71,7 @@ void LLFixedBuffer::addWLine(const LLWString& line) mMutex.lock() ; mLines.push_back(line); mLineLengths.push_back((S32)line.length()); - mAddTimes.push_back(mTimer.getElapsedTimeF32()); + mAddTimes.emplace_back(mTimer.getElapsedTimeF32()); mMutex.unlock() ; } diff --git a/indra/llcommon/llstacktrace.cpp b/indra/llcommon/llstacktrace.cpp index 80057bf0f21..8a136f0f6c8 100644 --- a/indra/llcommon/llstacktrace.cpp +++ b/indra/llcommon/llstacktrace.cpp @@ -106,11 +106,11 @@ bool ll_get_stack_trace(std::vector<std::string>& lines) if(ret) { std::string file_name = line.FileName; - std::string::size_type index = file_name.rfind("\\"); + std::string::size_type index = file_name.rfind('\\'); stack_line << file_name.substr(index + 1, file_name.size()) << ":" << line.LineNumber; } - lines.push_back(stack_line.str()); + lines.emplace_back(stack_line.str()); } free(pSym); diff --git a/indra/llcommon/llstreamqueue.h b/indra/llcommon/llstreamqueue.h index 0726bad1757..8d7e9d8d5be 100644 --- a/indra/llcommon/llstreamqueue.h +++ b/indra/llcommon/llstreamqueue.h @@ -134,7 +134,7 @@ class LLGenericStreamQueue // you might have to recopy all previous contents to grow its size. If // we want this to scale to large data volumes, better to allocate // individual pieces. - mBuffer.push_back(string(s, n)); + mBuffer.emplace_back(string(s, n)); mSize += n; return n; } diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 4d63492a4ed..fea9cb10b80 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -1329,7 +1329,6 @@ bool LLStringUtil::formatDatetime(std::string& replacement, std::string token, // if never fell into those two ifs above, param must be utc if (secFromEpoch < 0) secFromEpoch = 0; - LLDate datetime((F64)secFromEpoch); std::string code = LLStringOps::getDatetimeCode (token); // special case to handle timezone @@ -1340,7 +1339,7 @@ bool LLStringUtil::formatDatetime(std::string& replacement, std::string token, } else if (param == "local") { - replacement = ""; // user knows their own timezone + replacement.clear(); // user knows their own timezone } else { @@ -1400,6 +1399,7 @@ bool LLStringUtil::formatDatetime(std::string& replacement, std::string token, } else { + LLDate datetime((F64)secFromEpoch); replacement = datetime.toHTTPDateString(code); } -- GitLab