From dbc9a564c5894d8907effbc4d57f0827150ae2a8 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Thu, 1 Oct 2020 01:27:41 -0400 Subject: [PATCH] Misc cleanup of strings, const ref, and container emplacement --- indra/llmath/llcamera.cpp | 2 +- indra/llmath/lloctree.h | 7 +++--- indra/llmath/llvolume.cpp | 36 +++++++++++++-------------- indra/llmath/llvolume.h | 2 +- indra/llmath/llvolumemgr.cpp | 4 +-- indra/llmath/m3math.cpp | 3 ++- indra/llmath/m4math.cpp | 3 ++- indra/llmath/raytrace.cpp | 8 +++--- indra/llmath/raytrace.h | 8 +++--- indra/llmessage/llavatarname.cpp | 2 +- indra/llmessage/llavatarnamecache.cpp | 1 - indra/llmessage/llcachename.cpp | 2 +- indra/llmessage/llchainio.h | 4 +-- indra/llmessage/llhost.cpp | 2 +- indra/llmessage/lliohttpserver.cpp | 2 +- indra/llmessage/message.cpp | 12 ++++----- 16 files changed, 48 insertions(+), 50 deletions(-) diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp index 1e2031b430a..e37c97b1389 100644 --- a/indra/llmath/llcamera.cpp +++ b/indra/llmath/llcamera.cpp @@ -568,7 +568,7 @@ void LLCamera::calculateFrustumPlanes() calculateFrustumPlanes(left, right, top, bottom); } -LLPlane planeFromPoints(LLVector3 p1, LLVector3 p2, LLVector3 p3) +LLPlane planeFromPoints(const LLVector3& p1, const LLVector3& p2, const LLVector3& p3) { LLVector3 n = ((p2-p1)%(p3-p1)); n.normVec(); diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index f6d254d1571..127d041b4a7 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -107,7 +107,9 @@ class LLOctreeNode : public LLTreeNode<T> const LLVector4a& size, BaseType* parent, U8 octant = 255) - : mParent((oct_node*)parent), + : mCenter(center), + mSize(size), + mParent((oct_node*)parent), mOctant(octant) { llassert(size[0] >= gOctreeMinSize*0.5f); @@ -115,9 +117,6 @@ class LLOctreeNode : public LLTreeNode<T> mData.push_back(NULL); mDataEnd = &mData[0]; - mCenter = center; - mSize = size; - updateMinMax(); if ((mOctant == 255) && mParent) { diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 185a10088cf..ae29ceeaf72 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -1373,9 +1373,10 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en c = cos(ang)*lerp(radius_start, radius_end, t); - pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s) + const LLVector2& shearval = params.getShear(); + pt->mPos.set(0 + lerp(0,shearval.mV[0],s) + lerp(-skew ,skew, t) * 0.5f, - c + lerp(0,params.getShear().mV[1],s), + c + lerp(0,shearval.mV[1],s), s); pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t), hole_y * lerp(taper_y_begin, taper_y_end, t), @@ -3556,7 +3557,7 @@ bool LLVolumeParams::setSkew(const F32 skew_value) return valid; } -bool LLVolumeParams::setSculptID(const LLUUID sculpt_id, U8 sculpt_type) +bool LLVolumeParams::setSculptID(LLUUID sculpt_id, U8 sculpt_type) { mSculptID = std::move(sculpt_id); mSculptType = sculpt_type; @@ -3763,19 +3764,19 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, LLVector4a t; mat.affineTransform(v[v1], t); - vertices.push_back(LLVector3(t[0], t[1], t[2])); + vertices.emplace_back(LLVector3(t[0], t[1], t[2])); norm_mat.rotate(n[v1], t); t.normalize3fast(); - normals.push_back(LLVector3(t[0], t[1], t[2])); + normals.emplace_back(LLVector3(t[0], t[1], t[2])); mat.affineTransform(v[v2], t); - vertices.push_back(LLVector3(t[0], t[1], t[2])); + vertices.emplace_back(LLVector3(t[0], t[1], t[2])); norm_mat.rotate(n[v2], t); t.normalize3fast(); - normals.push_back(LLVector3(t[0], t[1], t[2])); + normals.emplace_back(LLVector3(t[0], t[1], t[2])); } } } @@ -3947,19 +3948,19 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, LLVector4a t; mat.affineTransform(v[v1], t); - vertices.push_back(LLVector3(t[0], t[1], t[2])); + vertices.emplace_back(LLVector3(t[0], t[1], t[2])); norm_mat.rotate(n[v1], t); t.normalize3fast(); - normals.push_back(LLVector3(t[0], t[1], t[2])); + normals.emplace_back(LLVector3(t[0], t[1], t[2])); mat.affineTransform(v[v2], t); - vertices.push_back(LLVector3(t[0], t[1], t[2])); + vertices.emplace_back(LLVector3(t[0], t[1], t[2])); norm_mat.rotate(n[v2], t); t.normalize3fast(); - normals.push_back(LLVector3(t[0], t[1], t[2])); + normals.emplace_back(LLVector3(t[0], t[1], t[2])); } } } @@ -4131,10 +4132,8 @@ class LLVertexIndexPair }; LLVertexIndexPair::LLVertexIndexPair(const LLVector3 &vertex, const S32 index) -{ - mVertex = vertex; - mIndex = index; -} + : mVertex(vertex), mIndex(index) +{ } const F32 VERTEX_SLOP = 0.00001f; @@ -5692,12 +5691,13 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) { + const LLPathParams& path_params = volume->getParams().getPathParams(); if (!(mTypeMask & HOLLOW_MASK) && !(mTypeMask & OPEN_MASK) && - ((volume->getParams().getPathParams().getBegin()==0.0f)&& - (volume->getParams().getPathParams().getEnd()==1.0f))&& + ((path_params.getBegin()==0.0f)&& + (path_params.getEnd()==1.0f))&& (volume->getParams().getProfileParams().getCurveType()==LL_PCODE_PROFILE_SQUARE && - volume->getParams().getPathParams().getCurveType()==LL_PCODE_PATH_LINE) + path_params.getCurveType()==LL_PCODE_PATH_LINE) ){ return createUnCutCubeCap(volume, partial_build); } diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index f389119c47d..5284b1aaaeb 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -619,7 +619,7 @@ class LLVolumeParams bool setRevolutions(const F32 revolutions); // 1 to 4 bool setRadiusOffset(const F32 radius_offset); bool setSkew(const F32 skew); - bool setSculptID(const LLUUID sculpt_id, U8 sculpt_type); + bool setSculptID(LLUUID sculpt_id, U8 sculpt_type); static bool validate(U8 prof_curve, F32 prof_begin, F32 prof_end, F32 hollow, U8 path_curve, F32 path_begin, F32 path_end, diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp index 89cdb1c6b91..a8e9ce69f30 100644 --- a/indra/llmath/llvolumemgr.cpp +++ b/indra/llmath/llvolumemgr.cpp @@ -68,7 +68,7 @@ BOOL LLVolumeMgr::cleanup() } for (volume_lod_group_map_t::iterator iter = mVolumeLODGroups.begin(), end = mVolumeLODGroups.end(); - iter != end; iter++) + iter != end; ++iter) { LLVolumeLODGroup *volgroupp = iter->second; if (volgroupp->cleanupRefs() == false) @@ -196,7 +196,7 @@ void LLVolumeMgr::dump() } for (volume_lod_group_map_t::iterator iter = mVolumeLODGroups.begin(), end = mVolumeLODGroups.end(); - iter != end; iter++) + iter != end; ++iter) { LLVolumeLODGroup *volgroupp = iter->second; avg += volgroupp->dump(); diff --git a/indra/llmath/m3math.cpp b/indra/llmath/m3math.cpp index 65eb3348de4..8e5fcb82b9b 100644 --- a/indra/llmath/m3math.cpp +++ b/indra/llmath/m3math.cpp @@ -244,7 +244,6 @@ LLQuaternion LLMatrix3::quaternion() const LLQuaternion quat; F32 tr, s, q[4]; U32 i, j, k; - U32 nxt[3] = {1, 2, 0}; tr = mMatrix[0][0] + mMatrix[1][1] + mMatrix[2][2]; @@ -260,6 +259,8 @@ LLQuaternion LLMatrix3::quaternion() const } else { + const U32 nxt[3] = { 1, 2, 0 }; + // diagonal is negative i = 0; if (mMatrix[1][1] > mMatrix[0][0]) diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp index fa774263b68..7cd9625ed4a 100644 --- a/indra/llmath/m4math.cpp +++ b/indra/llmath/m4math.cpp @@ -308,7 +308,6 @@ LLQuaternion LLMatrix4::quaternion() const LLQuaternion quat; F32 tr, s, q[4]; U32 i, j, k; - U32 nxt[3] = {1, 2, 0}; tr = mMatrix[0][0] + mMatrix[1][1] + mMatrix[2][2]; @@ -324,6 +323,8 @@ LLQuaternion LLMatrix4::quaternion() const } else { + const U32 nxt[3] = { 1, 2, 0 }; + // diagonal is negative i = 0; if (mMatrix[1][1] > mMatrix[0][0]) diff --git a/indra/llmath/raytrace.cpp b/indra/llmath/raytrace.cpp index f38fe49bcbf..bf161fbccf4 100644 --- a/indra/llmath/raytrace.cpp +++ b/indra/llmath/raytrace.cpp @@ -35,7 +35,7 @@ BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction, - const LLVector3 &plane_point, const LLVector3 plane_normal, + const LLVector3 &plane_point, const LLVector3 &plane_normal, LLVector3 &intersection) { F32 N = line_direction * plane_normal; @@ -55,7 +55,7 @@ BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction, BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, - const LLVector3 &plane_point, const LLVector3 plane_normal, + const LLVector3 &plane_point, const LLVector3 &plane_normal, LLVector3 &intersection) { F32 N = ray_direction * plane_normal; @@ -81,7 +81,7 @@ BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, BOOL ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction, - const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius, + const LLVector3 &circle_center, const LLVector3 &plane_normal, F32 circle_radius, LLVector3 &intersection) { if (ray_plane(ray_point, ray_direction, circle_center, plane_normal, intersection)) @@ -1105,7 +1105,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, BOOL linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b, - const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius, + const LLVector3 &circle_center, const LLVector3 &plane_normal, F32 circle_radius, LLVector3 &intersection) { LLVector3 ray_direction = point_b - point_a; diff --git a/indra/llmath/raytrace.h b/indra/llmath/raytrace.h index 2d32af0c866..c482a4b4169 100644 --- a/indra/llmath/raytrace.h +++ b/indra/llmath/raytrace.h @@ -63,18 +63,18 @@ class LLQuaternion; // returns TRUE iff line is not parallel to plane. BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction, - const LLVector3 &plane_point, const LLVector3 plane_normal, + const LLVector3 &plane_point, const LLVector3 &plane_normal, LLVector3 &intersection); // returns TRUE iff line is not parallel to plane. BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, - const LLVector3 &plane_point, const LLVector3 plane_normal, + const LLVector3 &plane_point, const LLVector3 &plane_normal, LLVector3 &intersection); BOOL ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction, - const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius, + const LLVector3 &circle_center, const LLVector3 &plane_normal, F32 circle_radius, LLVector3 &intersection); // point_0 through point_2 define the plane_normal via the right-hand rule: @@ -171,7 +171,7 @@ BOOL ray_hemicone(const LLVector3 &ray_point, const LLVector3 &ray_direction, BOOL linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b, - const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius, + const LLVector3 &circle_center, const LLVector3 &plane_normal, F32 circle_radius, LLVector3 &intersection); // point_0 through point_2 define the plane_normal via the right-hand rule: diff --git a/indra/llmessage/llavatarname.cpp b/indra/llmessage/llavatarname.cpp index 7e1246f8857..3e1545b7170 100644 --- a/indra/llmessage/llavatarname.cpp +++ b/indra/llmessage/llavatarname.cpp @@ -152,7 +152,7 @@ void LLAvatarName::fromString(const std::string& full_name) else { mLegacyFirstName = full_name; - mLegacyLastName = ""; + mLegacyLastName.clear(); mUsername = full_name; mDisplayName = full_name; } diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index c7931befecf..117d1c2da6a 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -402,7 +402,6 @@ void LLAvatarNameCache::requestNamesViaLegacy() { static const S32 MAX_REQUESTS = 100; F64 now = LLFrameTimer::getTotalSeconds(); - std::string full_name; ask_queue_t::const_iterator it; for (S32 requests = 0; !mAskQueue.empty() && requests < MAX_REQUESTS; ++requests) { diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 0064b10fefb..47762946292 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -434,7 +434,7 @@ BOOL LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::strin // static void LLCacheName::localizeCacheName(std::string key, std::string value) { - if (key!="" && value!= "" ) + if (!key.empty() && !value.empty()) sCacheName[key]=value; else LL_WARNS()<< " Error localizing cache key " << key << " To "<< value<<LL_ENDL; diff --git a/indra/llmessage/llchainio.h b/indra/llmessage/llchainio.h index 6e4d6c20138..db5a907d1e4 100644 --- a/indra/llmessage/llchainio.h +++ b/indra/llmessage/llchainio.h @@ -104,7 +104,7 @@ class LLSimpleIOFactory : public LLChainIOFactory public: virtual bool build(LLPumpIO::chain_t& chain, LLSD context) const { - chain.push_back(LLIOPipe::ptr_t(new Pipe)); + chain.emplace_back(LLIOPipe::ptr_t(new Pipe)); return true; } }; @@ -123,7 +123,7 @@ class LLCloneIOFactory : public LLChainIOFactory virtual bool build(LLPumpIO::chain_t& chain, LLSD context) const { - chain.push_back(LLIOPipe::ptr_t(new Pipe(*mOriginal))); + chain.emplace_back(LLIOPipe::ptr_t(new Pipe(*mOriginal))); return true; } diff --git a/indra/llmessage/llhost.cpp b/indra/llmessage/llhost.cpp index 337b34922d9..00b32a676ab 100644 --- a/indra/llmessage/llhost.cpp +++ b/indra/llmessage/llhost.cpp @@ -43,7 +43,7 @@ LLHost::LLHost(const std::string& ip_and_port) { - std::string::size_type colon_index = ip_and_port.find(":"); + std::string::size_type colon_index = ip_and_port.find(':'); if (colon_index == std::string::npos) { mIP = ip_string_to_u32(ip_and_port.c_str()); diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index d9042fa8b03..d85d802f8d3 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -725,7 +725,7 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl( if (delimiter == std::string::npos) { mPath = mAbsPathAndQuery; - mQuery = ""; + mQuery.clear(); } else { diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index 5c5245f5913..06fe866dbfd 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -400,7 +400,7 @@ bool LLMessageSystem::isTrustedSender() const static LLMessageSystem::message_template_name_map_t::const_iterator findTemplate(const LLMessageSystem::message_template_name_map_t& templates, - std::string name) + const std::string& name) { const char* namePrehash = LLMessageStringTable::getInstance()->getString(name.c_str()); if(NULL == namePrehash) {return templates.end();} @@ -2054,7 +2054,7 @@ void LLMessageSystem::dispatch( return; } - std::string path = "/message/" + msg_name; + std::string path = absl::StrCat("/message/", msg_name); LLSD context; const LLHTTPNode* handler = messageRootNode().traverse(path, context); if (!handler) @@ -2112,7 +2112,7 @@ void LLMessageSystem::setMessageBans( { LLMessageTemplate* mt = iter->second; - std::string name(mt->mName); + std::string_view name(mt->mName); bool ban_from_trusted = trusted.has(name) && trusted.get(name).asBoolean(); bool ban_from_untrusted @@ -2254,8 +2254,7 @@ void process_create_trusted_circuit(LLMessageSystem *msg, void **) return; } - LLUUID local_id; - local_id = cdp->getLocalEndPointID(); + const LLUUID& local_id = cdp->getLocalEndPointID(); if (remote_id == local_id) { // Don't respond to requests that use the same end point ID @@ -2328,8 +2327,7 @@ void process_deny_trusted_circuit(LLMessageSystem *msg, void **) return; } - LLUUID local_id; - local_id = cdp->getLocalEndPointID(); + const LLUUID& local_id = cdp->getLocalEndPointID(); if (remote_id == local_id) { // Don't respond to requests that use the same end point ID -- GitLab