diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-12-18 20:06:05 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-12-18 20:06:05 +0000 |
commit | 90c861d4818ba4e8cf91f624656a24064e4995eb (patch) | |
tree | f7225b44eb6be67fc6bc4b5b53e70274400d7f20 /searchlib | |
parent | ff33b319cac87159ae31b005228ea40d5bb718d5 (diff) |
std::make_unique
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/common/bitvector.cpp | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/searchlib/src/vespa/searchlib/common/bitvector.cpp b/searchlib/src/vespa/searchlib/common/bitvector.cpp index ece025454c9..ddc4f7af944 100644 --- a/searchlib/src/vespa/searchlib/common/bitvector.cpp +++ b/searchlib/src/vespa/searchlib/common/bitvector.cpp @@ -297,27 +297,21 @@ BitVector::getFileBytes(Index bits) class MMappedBitVector : public BitVector { public: - MMappedBitVector(Index numberOfElements, - FastOS_FileInterface &file, - int64_t offset, - Index doccount); + MMappedBitVector(Index numberOfElements, FastOS_FileInterface &file, + int64_t offset, Index doccount); private: - void read(Index numberOfElements, - FastOS_FileInterface &file, - int64_t offset, - Index doccount); + void read(Index numberOfElements, FastOS_FileInterface &file, + int64_t offset, Index doccount); }; BitVector::UP -BitVector::create(Index numberOfElements, - FastOS_FileInterface &file, - int64_t offset, - Index doccount) +BitVector::create(Index numberOfElements, FastOS_FileInterface &file, + int64_t offset, Index doccount) { UP bv; if (file.IsMemoryMapped()) { - bv.reset(new MMappedBitVector(numberOfElements, file, offset, doccount)); + bv = std::make_unique<MMappedBitVector>(numberOfElements, file, offset, doccount); } else { size_t padbefore, padafter; size_t vectorsize = getFileBytes(numberOfElements); @@ -326,7 +320,7 @@ BitVector::create(Index numberOfElements, AllocatedBitVector::Alloc alloc = Alloc::alloc(padbefore + vectorsize + padafter, 0x1000000, 0x1000); void * alignedBuffer = alloc.get(); file.ReadBuf(alignedBuffer, alloc.size(), offset - padbefore); - bv.reset(new AllocatedBitVector(numberOfElements, std::move(alloc), padbefore)); + bv = std::make_unique<AllocatedBitVector>(numberOfElements, std::move(alloc), padbefore); bv->setTrueBits(doccount); // Check guard bit for getNextTrueBit() assert(bv->testBit(bv->size())); @@ -339,7 +333,7 @@ BitVector::create(Index start, Index end) { return (start == 0) ? create(end) - : UP(new PartialBitVector(start, end)); + : std::make_unique<PartialBitVector>(start, end); } BitVector::UP @@ -347,46 +341,42 @@ BitVector::create(const BitVector & org, Index start, Index end) { return (start == 0) ? create(end) - : UP(new PartialBitVector(org, start, end)); + : std::make_unique<PartialBitVector>(org, start, end); } BitVector::UP BitVector::create(Index numberOfElements) { - return UP(new AllocatedBitVector(numberOfElements)); + return std::make_unique<AllocatedBitVector>(numberOfElements); } BitVector::UP BitVector::create(const BitVector & rhs) { - return UP(new AllocatedBitVector(rhs)); + return std::make_unique<AllocatedBitVector>(rhs); } BitVector::UP BitVector::create(Index numberOfElements, Index newCapacity, GenerationHolder &generationHolder) { - return UP(new GrowableBitVector(numberOfElements, newCapacity, generationHolder)); + return std::make_unique<GrowableBitVector>(numberOfElements, newCapacity, generationHolder); } -MMappedBitVector::MMappedBitVector(Index numberOfElements, - FastOS_FileInterface &file, - int64_t offset, - Index doccount) : +MMappedBitVector::MMappedBitVector(Index numberOfElements, FastOS_FileInterface &file, + int64_t offset, Index doccount) : BitVector() { read(numberOfElements, file, offset, doccount); } void -MMappedBitVector::read(Index numberOfElements, - FastOS_FileInterface &file, - int64_t offset, - Index doccount) +MMappedBitVector::read(Index numberOfElements, FastOS_FileInterface &file, + int64_t offset, Index doccount) { assert((offset & (getAlignment() - 1)) == 0); void *mapptr = file.MemoryMapPtr(offset); - assert(mapptr != NULL); - if (mapptr != NULL) { + assert(mapptr != nullptr); + if (mapptr != nullptr) { init(mapptr, 0, numberOfElements); } setTrueBits(doccount); |