Skip to content

Commit 54b3f3d

Browse files
authored
#5072 Use make_shared for more efficient ref counting and allocation
1 parent bae1e10 commit 54b3f3d

File tree

103 files changed

+506
-514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+506
-514
lines changed

indra/llcharacter/llkeyframemotion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8
12291229
bool LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, bool allow_invalid_joints)
12301230
{
12311231
bool old_version = false;
1232-
std::unique_ptr<LLKeyframeMotion::JointMotionList> joint_motion_list(new LLKeyframeMotion::JointMotionList);
1232+
std::unique_ptr<LLKeyframeMotion::JointMotionList> joint_motion_list = std::make_unique<LLKeyframeMotion::JointMotionList>();
12331233

12341234
//-------------------------------------------------------------------------
12351235
// get base priority
@@ -1826,7 +1826,7 @@ bool LLKeyframeMotion::deserialize(LLDataPacker& dp, const LLUUID& asset_id, boo
18261826
for(S32 i = 0; i < num_constraints; ++i)
18271827
{
18281828
// read in constraint data
1829-
std::unique_ptr<JointConstraintSharedData> constraintp(new JointConstraintSharedData);
1829+
std::unique_ptr<JointConstraintSharedData> constraintp = std::make_unique<JointConstraintSharedData>();
18301830
U8 byte = 0;
18311831

18321832
if (!dp.unpackU8(byte, "chain_length"))

indra/llcommon/llapr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ LLVolatileAPRPool::LLVolatileAPRPool(bool is_local, apr_pool_t *parent, apr_size
154154
//create mutex
155155
if(!is_local) //not a local apr_pool, that is: shared by multiple threads.
156156
{
157-
mMutexp.reset(new std::mutex());
157+
mMutexp = std::make_unique<std::mutex>();
158158
}
159159
}
160160

indra/llcommon/llleap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class LLLeapImpl: public LLLeap
6161
// Pass it a callback to our connect() method, so it can send events
6262
// from a particular LLEventPump to the plugin without having to know
6363
// this class or method name.
64-
mListener(new LLLeapListener(
64+
mListener(std::make_unique<LLLeapListener>(
6565
[this](LLEventPump& pump, const std::string& listener)
6666
{ return connect(pump, listener); }))
6767
{

indra/llcommon/llstring.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,9 @@ void LLStringUtilBase<T>::getTokens(const string_type& string, std::vector<strin
12341234
// (unless there ARE no escapes).
12351235
std::unique_ptr< LLStringUtilBaseImpl::InString<T> > instrp;
12361236
if (escapes.empty())
1237-
instrp.reset(new LLStringUtilBaseImpl::InString<T>(string.begin(), string.end()));
1237+
instrp = std::make_unique<LLStringUtilBaseImpl::InString<T>>(string.begin(), string.end());
12381238
else
1239-
instrp.reset(new LLStringUtilBaseImpl::InEscString<T>(string.begin(), string.end(), escapes));
1239+
instrp = std::make_unique<LLStringUtilBaseImpl::InEscString<T>>(string.begin(), string.end(), escapes);
12401240
LLStringUtilBaseImpl::getTokens(*instrp, tokens, drop_delims, keep_delims, quotes);
12411241
}
12421242

indra/llcorehttp/_httpoprequest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void HttpOpRequest::visitNotifier(HttpRequest * request)
272272
response->setContentType(mReplyConType);
273273
response->setRetries(mPolicyRetries, mPolicy503Retries);
274274

275-
HttpResponse::TransferStats::ptr_t stats = HttpResponse::TransferStats::ptr_t(new HttpResponse::TransferStats);
275+
HttpResponse::TransferStats::ptr_t stats = std::make_shared<HttpResponse::TransferStats>();
276276

277277
curl_easy_getinfo(mCurlHandle, CURLINFO_SIZE_DOWNLOAD, &stats->mSizeDownload);
278278
curl_easy_getinfo(mCurlHandle, CURLINFO_TOTAL_TIME, &stats->mTotalTime);
@@ -964,7 +964,7 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi
964964
// Save headers in response
965965
if (! op->mReplyHeaders)
966966
{
967-
op->mReplyHeaders = HttpHeaders::ptr_t(new HttpHeaders);
967+
op->mReplyHeaders = std::make_shared<HttpHeaders>();
968968
}
969969
op->mReplyHeaders->append(name, value ? value : "");
970970
}

indra/llcorehttp/httpcommon.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,25 +297,25 @@ struct HttpStatus
297297

298298
HttpStatus()
299299
{
300-
mDetails = std::shared_ptr<Details>(new Details(LLCORE, HE_SUCCESS));
300+
mDetails = std::make_shared<Details>(LLCORE, HE_SUCCESS);
301301
}
302302

303303
HttpStatus(type_enum_t type, short status)
304304
{
305-
mDetails = std::shared_ptr<Details>(new Details(type, status));
305+
mDetails = std::make_shared<Details>(type, status);
306306
}
307307

308308
HttpStatus(int http_status)
309309
{
310-
mDetails = std::shared_ptr<Details>(new Details(http_status,
311-
(http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR));
310+
mDetails = std::make_shared<Details>(http_status,
311+
(http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR);
312312
llassert(http_status >= 100 && http_status <= 999);
313313
}
314314

315315
HttpStatus(int http_status, const std::string &message)
316316
{
317-
mDetails = std::shared_ptr<Details>(new Details(http_status,
318-
(http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR));
317+
mDetails = std::make_shared<Details>(http_status,
318+
(http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR);
319319
llassert(http_status >= 100 && http_status <= 999);
320320
mDetails->mMessage = message;
321321
}
@@ -337,7 +337,7 @@ struct HttpStatus
337337

338338
HttpStatus & clone(const HttpStatus &rhs)
339339
{
340-
mDetails = std::shared_ptr<Details>(new Details(*rhs.mDetails));
340+
mDetails = std::make_shared<Details>(*rhs.mDetails);
341341
return *this;
342342
}
343343

indra/llcorehttp/httprequest.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ HttpRequest::HttpRequest()
6060
mRequestQueue = HttpRequestQueue::instanceOf();
6161
mRequestQueue->addRef();
6262

63-
mReplyQueue.reset( new HttpReplyQueue() );
63+
mReplyQueue = std::make_shared<HttpReplyQueue>();
6464

6565
HTTPStats::instance().recordHTTPRequest();
6666
}
@@ -129,7 +129,7 @@ HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass,
129129
{
130130
HttpStatus status;
131131

132-
HttpOpSetGet::ptr_t op(new HttpOpSetGet());
132+
HttpOpSetGet::ptr_t op = std::make_shared<HttpOpSetGet>();
133133
if (! (status = op->setupSet(opt, pclass, value)))
134134
{
135135
mLastReqStatus = status;
@@ -152,7 +152,7 @@ HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass,
152152
{
153153
HttpStatus status;
154154

155-
HttpOpSetGet::ptr_t op (new HttpOpSetGet());
155+
HttpOpSetGet::ptr_t op = std::make_shared<HttpOpSetGet>();
156156
if (! (status = op->setupSet(opt, pclass, value)))
157157
{
158158
mLastReqStatus = status;
@@ -190,7 +190,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id,
190190
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
191191
HttpStatus status;
192192

193-
HttpOpRequest::ptr_t op(new HttpOpRequest());
193+
HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
194194
if (! (status = op->setupGet(policy_id, url, options, headers)))
195195
{
196196
mLastReqStatus = status;
@@ -219,7 +219,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id,
219219
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
220220
HttpStatus status;
221221

222-
HttpOpRequest::ptr_t op(new HttpOpRequest());
222+
HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
223223
if (! (status = op->setupGetByteRange(policy_id, url, offset, len, options, headers)))
224224
{
225225
mLastReqStatus = status;
@@ -246,7 +246,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id,
246246
{
247247
HttpStatus status;
248248

249-
HttpOpRequest::ptr_t op(new HttpOpRequest());
249+
HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
250250
if (! (status = op->setupPost(policy_id, url, body, options, headers)))
251251
{
252252
mLastReqStatus = status;
@@ -273,7 +273,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id,
273273
{
274274
HttpStatus status;
275275

276-
HttpOpRequest::ptr_t op (new HttpOpRequest());
276+
HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
277277
if (! (status = op->setupPut(policy_id, url, body, options, headers)))
278278
{
279279
mLastReqStatus = status;
@@ -298,7 +298,7 @@ HttpHandle HttpRequest::requestDelete(policy_t policy_id,
298298
{
299299
HttpStatus status;
300300

301-
HttpOpRequest::ptr_t op(new HttpOpRequest());
301+
HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
302302
if (!(status = op->setupDelete(policy_id, url, options, headers)))
303303
{
304304
mLastReqStatus = status;
@@ -324,7 +324,7 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id,
324324
{
325325
HttpStatus status;
326326

327-
HttpOpRequest::ptr_t op (new HttpOpRequest());
327+
HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
328328
if (!(status = op->setupPatch(policy_id, url, body, options, headers)))
329329
{
330330
mLastReqStatus = status;
@@ -349,7 +349,7 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id,
349349
{
350350
HttpStatus status;
351351

352-
HttpOpRequest::ptr_t op(new HttpOpRequest());
352+
HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
353353
if (!(status = op->setupCopy(policy_id, url, options, headers)))
354354
{
355355
mLastReqStatus = status;
@@ -375,7 +375,7 @@ HttpHandle HttpRequest::requestMove(policy_t policy_id,
375375
{
376376
HttpStatus status;
377377

378-
HttpOpRequest::ptr_t op (new HttpOpRequest());
378+
HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
379379
if (!(status = op->setupMove(policy_id, url, options, headers)))
380380
{
381381
mLastReqStatus = status;
@@ -397,7 +397,7 @@ HttpHandle HttpRequest::requestNoOp(HttpHandler::ptr_t user_handler)
397397
{
398398
HttpStatus status;
399399

400-
HttpOperation::ptr_t op (new HttpOpNull());
400+
HttpOperation::ptr_t op = std::make_shared<HttpOpNull>();
401401
op->setReplyPath(mReplyQueue, user_handler);
402402
if (! (status = mRequestQueue->addOp(op))) // transfers refcount
403403
{
@@ -463,7 +463,7 @@ HttpHandle HttpRequest::requestCancel(HttpHandle request, HttpHandler::ptr_t use
463463
{
464464
HttpStatus status;
465465

466-
HttpOperation::ptr_t op(new HttpOpCancel(request));
466+
HttpOperation::ptr_t op = std::make_shared<HttpOpCancel>(request);
467467
op->setReplyPath(mReplyQueue, user_handler);
468468
if (! (status = mRequestQueue->addOp(op))) // transfers refcount
469469
{
@@ -528,7 +528,7 @@ HttpHandle HttpRequest::requestStopThread(HttpHandler::ptr_t user_handler)
528528
HttpStatus status;
529529
HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID);
530530

531-
HttpOperation::ptr_t op(new HttpOpStop());
531+
HttpOperation::ptr_t op = std::make_shared<HttpOpStop>();
532532
op->setReplyPath(mReplyQueue, user_handler);
533533
if (! (status = mRequestQueue->addOp(op))) // transfers refcount
534534
{
@@ -548,7 +548,7 @@ HttpHandle HttpRequest::requestSpin(int mode)
548548
HttpStatus status;
549549
HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID);
550550

551-
HttpOperation::ptr_t op(new HttpOpSpin(mode));
551+
HttpOperation::ptr_t op = std::make_shared<HttpOpSpin>(mode);
552552
op->setReplyPath(mReplyQueue, HttpHandler::ptr_t());
553553
if (! (status = mRequestQueue->addOp(op))) // transfers refcount
554554
{

indra/llcorehttp/httprequest.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ class HttpRequest
104104

105105
/// Represents a default, catch-all policy class that guarantees
106106
/// eventual service for any HTTP request.
107-
static const policy_t DEFAULT_POLICY_ID = 0;
108-
static const policy_t INVALID_POLICY_ID = 0xFFFFFFFFU;
109-
static const policy_t GLOBAL_POLICY_ID = 0xFFFFFFFEU;
107+
static constexpr policy_t DEFAULT_POLICY_ID = 0;
108+
static constexpr policy_t INVALID_POLICY_ID = 0xFFFFFFFFU;
109+
static constexpr policy_t GLOBAL_POLICY_ID = 0xFFFFFFFEU;
110110

111111
/// Create a new policy class into which requests can be made.
112112
///

indra/llimage/llimageworker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ImageRequest
6767
LLImageDecodeThread::LLImageDecodeThread(bool /*threaded*/)
6868
: mDecodeCount(0)
6969
{
70-
mThreadPool.reset(new LL::ThreadPool("ImageDecode", 8));
70+
mThreadPool = std::make_unique<LL::ThreadPool>("ImageDecode", 8);
7171
mThreadPool->start();
7272
}
7373

indra/llmessage/llavatarnamecache.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ LLAvatarNameCache::LLAvatarNameCache()
117117

118118
mUsePeopleAPI = true;
119119

120-
sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest());
121-
sHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders());
122-
sHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions());
120+
sHttpRequest = std::make_shared<LLCore::HttpRequest>();
121+
sHttpHeaders = std::make_shared<LLCore::HttpHeaders>();
122+
sHttpOptions = std::make_shared<LLCore::HttpOptions>();
123123
sHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID;
124124
}
125125

0 commit comments

Comments
 (0)