File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -784,7 +784,7 @@ void SPIRVModuleImpl::addCapability(SPIRVCapabilityKind Cap) {
784784 SPIRVDBG (spvdbgs () << " addCapability: " << SPIRVCapabilityNameMap::map (Cap)
785785 << ' \n ' );
786786
787- auto [It, Inserted] = CapMap.insert ( std::make_pair ( Cap, nullptr ) );
787+ auto [It, Inserted] = CapMap.try_emplace ( Cap);
788788 if (!Inserted)
789789 return ;
790790
@@ -802,10 +802,11 @@ void SPIRVModuleImpl::addCapability(SPIRVCapabilityKind Cap) {
802802
803803void SPIRVModuleImpl::addCapabilityInternal (SPIRVCapabilityKind Cap) {
804804 if (AutoAddCapability) {
805- if (hasCapability (Cap))
805+ auto [It, Inserted] = CapMap.try_emplace (Cap);
806+ if (!Inserted)
806807 return ;
807808
808- CapMap. insert ( std::make_pair (Cap, new SPIRVCapability (this , Cap)) );
809+ It-> second = std::make_unique< SPIRVCapability> (this , Cap);
809810 }
810811}
811812
@@ -815,7 +816,7 @@ void SPIRVModuleImpl::addConditionalCapability(SPIRVId Condition,
815816 << SPIRVCapabilityNameMap::map (Cap)
816817 << " , condition: " << Condition << ' \n ' );
817818 auto Key = std::make_pair (Condition, Cap);
818- auto [It, Inserted] = ConditionalCapMap.insert ({ Key, nullptr } );
819+ auto [It, Inserted] = ConditionalCapMap.try_emplace ( Key);
819820 if (!Inserted) {
820821 return ;
821822 }
You can’t perform that action at this time.
0 commit comments