Re: emplace question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 4, 2018 at 11:35 AM, Brad Hubbard <bhubbard@xxxxxxxxxx> wrote:
> On Wed, Apr 4, 2018 at 12:27 PM, Sage Weil <sweil@xxxxxxxxxx> wrote:
>> C++ question: is this patch necessary?
>>
>>         https://github.com/liewegas/ceph/commit/116ea627b4dabc1b2339e4e02450487c86433f41
>>
>> We want to avoid the OSDShardPGSlot allocation in the common case (where
>> the entry already exists).
>
> Geordi says it is necessary.
>
> badone | geordi: { using tracked::B; unordered_map<int, unique_ptr<B>>
> um; um.insert(make_pair(1, make_unique<B>())); um.emplace(make_pair(1,
> nullptr));}
> geordi | new(B) B0* B0~ delete(B0)
> badone | geordi: { using tracked::B; unordered_map<int, unique_ptr<B>>
> um; um.insert(make_pair(1, make_unique<B>())); um.emplace(make_pair(1,
> make_unique<B>()));}
> geordi | new(B) B0* new(B) B1* B1~ delete(B1) B0~ delete(B0)

agreed, i think that's why try_emplace() was added in C++17.



-- 
Regards
Kefu Chai
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux