diff options
-rw-r--r-- | src/mongo/db/s/collection_metadata.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_state.cpp | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/db/s/collection_metadata.cpp b/src/mongo/db/s/collection_metadata.cpp index cc650362677..734e55cfeba 100644 --- a/src/mongo/db/s/collection_metadata.cpp +++ b/src/mongo/db/s/collection_metadata.cpp @@ -84,7 +84,8 @@ CollectionMetadata::CollectionMetadata(const BSONObj& keyPattern, continue; } - _rangesMap.emplace(min, CachedChunkInfo(max, ChunkVersion::IGNORED())); + _rangesMap.emplace_hint( + _rangesMap.end(), min, CachedChunkInfo(max, ChunkVersion::IGNORED())); min = currMin; max = currMax; @@ -93,7 +94,7 @@ CollectionMetadata::CollectionMetadata(const BSONObj& keyPattern, invariant(!min.isEmpty()); invariant(!max.isEmpty()); - _rangesMap.emplace(min, CachedChunkInfo(max, ChunkVersion::IGNORED())); + _rangesMap.emplace_hint(_rangesMap.end(), min, CachedChunkInfo(max, ChunkVersion::IGNORED())); } CollectionMetadata::~CollectionMetadata() = default; diff --git a/src/mongo/db/s/sharding_state.cpp b/src/mongo/db/s/sharding_state.cpp index a0f0c5b1a4f..e264c82b57f 100644 --- a/src/mongo/db/s/sharding_state.cpp +++ b/src/mongo/db/s/sharding_state.cpp @@ -645,8 +645,9 @@ ChunkVersion ShardingState::_refreshMetadata(OperationContext* txn, const Namesp if (chunk->getShardId() != shardId) continue; - shardChunksMap.emplace(chunk->getMin(), - CachedChunkInfo(chunk->getMax(), chunk->getLastmod())); + shardChunksMap.emplace_hint(shardChunksMap.end(), + chunk->getMin(), + CachedChunkInfo(chunk->getMax(), chunk->getLastmod())); } return stdx::make_unique<CollectionMetadata>(cm->getShardKeyPattern().toBSON(), |