Don't move temporaries, so possibly allowing for copy elision.

Pointed out by clang's -Wpessimizing-move.

Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D421
This was SVN commit r19559.
This commit is contained in:
leper 2017-05-11 23:24:54 +00:00
parent 6e549bfed2
commit 51f7502bb1
4 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2015 Wildfire Games
/* Copyright (c) 2017 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -88,7 +88,7 @@ UniqueRange AllocateAligned(size_t size, size_t alignment)
if(idxDeleterAligned == 0) // (optional optimization)
RegisterUniqueRangeDeleter(FreeAligned, &idxDeleterAligned);
return std::move(UniqueRange(p, size, idxDeleterAligned));
return UniqueRange(p, size, idxDeleterAligned);
}
@ -100,5 +100,5 @@ UniqueRange AllocateVM(size_t size, vm::PageType pageType, int prot)
if(idxDeleter == 0) // (optional optimization)
RegisterUniqueRangeDeleter(vm::Free, &idxDeleter);
return std::move(UniqueRange(p, size, idxDeleter));
return UniqueRange(p, size, idxDeleter);
}

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2015 Wildfire Games
/* Copyright (c) 2017 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -448,7 +448,7 @@ public:
size_t cd_numEntries = 0;
size_t cd_size = 0;
RETURN_STATUS_IF_ERR(LocateCentralDirectory(m_file, m_fileSize, cd_ofs, cd_numEntries, cd_size));
UniqueRange buf(std::move(io::Allocate(cd_size)));
UniqueRange buf(io::Allocate(cd_size));
io::Operation op(*m_file.get(), buf.get(), cd_size, cd_ofs);
RETURN_STATUS_IF_ERR(io::Run(op));
@ -533,7 +533,7 @@ private:
static Status LocateCentralDirectory(const PFile& file, off_t fileSize, off_t& cd_ofs, size_t& cd_numEntries, size_t& cd_size)
{
const size_t maxScanSize = 66000u; // see below
UniqueRange buf(std::move(io::Allocate(maxScanSize)));
UniqueRange buf(io::Allocate(maxScanSize));
// expected case: ECDR at EOF; no file comment
Status ret = ScanForEcdr(file, fileSize, (u8*)buf.get(), sizeof(ECDR), cd_numEntries, cd_ofs, cd_size);
@ -662,7 +662,7 @@ public:
// allocate memory
const size_t csizeMax = codec->MaxOutputSize(size_t(usize));
UniqueRange buf(std::move(io::Allocate(sizeof(LFH) + pathnameLength + csizeMax)));
UniqueRange buf(io::Allocate(sizeof(LFH) + pathnameLength + csizeMax));
// read and compress file contents
size_t csize; u32 checksum;

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011 Wildfire Games
/* Copyright (c) 2017 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -54,7 +54,7 @@ namespace io {
// never reused (avoids displacing other items).
static inline UniqueRange Allocate(size_t size, size_t alignment = maxSectorSize)
{
return std::move(AllocateAligned(size, alignment));
return AllocateAligned(size, alignment);
}
@ -190,7 +190,7 @@ public:
const bool temporaryBuffersRequested = (op.buf == 0);
if(temporaryBuffersRequested)
buffers = std::move(io::Allocate(blockSize * p.queueDepth, p.alignment));
buffers = io::Allocate(blockSize * p.queueDepth, p.alignment);
for(size_t i = 0; i < ARRAY_SIZE(controlBlocks); i++)
{

View File

@ -546,7 +546,7 @@ void CComponentManager::SetRNGSeed(u32 seed)
void CComponentManager::RegisterComponentType(InterfaceId iid, ComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc,
const char* name, const std::string& schema)
{
ComponentType c(CT_Native, iid, alloc, dealloc, name, schema, std::move(DefPersistentRooted<JS::Value>()));
ComponentType c(CT_Native, iid, alloc, dealloc, name, schema, DefPersistentRooted<JS::Value>());
m_ComponentTypesById.insert(std::make_pair(cid, std::move(c)));
m_ComponentTypeIdsByName[name] = cid;
}
@ -554,7 +554,7 @@ void CComponentManager::RegisterComponentType(InterfaceId iid, ComponentTypeId c
void CComponentManager::RegisterComponentTypeScriptWrapper(InterfaceId iid, ComponentTypeId cid, AllocFunc alloc,
DeallocFunc dealloc, const char* name, const std::string& schema)
{
ComponentType c(CT_ScriptWrapper, iid, alloc, dealloc, name, schema, std::move(DefPersistentRooted<JS::Value>()));
ComponentType c(CT_ScriptWrapper, iid, alloc, dealloc, name, schema, DefPersistentRooted<JS::Value>());
m_ComponentTypesById.insert(std::make_pair(cid, std::move(c)));
m_ComponentTypeIdsByName[name] = cid;
// TODO: merge with RegisterComponentType