From db17a874af37350b3270932175854ee674447bc1 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 11 Aug 2017 11:36:47 +0200 Subject: convert std::map::insert to std::map::emplace II Change-Id: Ief8bd59c903625ba65b75114b7b52c3b7ecbd331 Reviewed-on: https://gerrit.libreoffice.org/41019 Tested-by: Jenkins Reviewed-by: Noel Grandin --- codemaker/source/cppumaker/cpputype.cxx | 14 ++++------- codemaker/source/cppumaker/dependencies.cxx | 3 +-- codemaker/source/cppumaker/includes.cxx | 3 +-- codemaker/source/javamaker/classfile.cxx | 36 +++++++++-------------------- codemaker/source/javamaker/javatype.cxx | 7 ++---- 5 files changed, 20 insertions(+), 43 deletions(-) (limited to 'codemaker') diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx index a8ac2ba4822c..28efa3fbf1f9 100644 --- a/codemaker/source/cppumaker/cpputype.cxx +++ b/codemaker/source/cppumaker/cpputype.cxx @@ -2025,9 +2025,8 @@ void PlainStructType::dumpComprehensiveGetCppuType(FileStream & out) std::map< OUString, sal_uInt32 > types; std::vector< unoidl::PlainStructTypeEntity::Member >::size_type n = 0; for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers()) { - if (types.insert( - std::map< OUString, sal_uInt32 >::value_type( - member.type, static_cast< sal_uInt32 >(types.size()))). + if (types.emplace( + member.type, static_cast< sal_uInt32 >(types.size())). second) { dumpCppuGetType(out, member.type, &name_); // For typedefs, use the resolved type name, as there will be no @@ -2530,9 +2529,8 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out) size_type n = 0; for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : entity_->getMembers()) { if (member.parameterized) { - if (parameters.insert( - std::map< OUString, sal_uInt32 >::value_type( - member.type, static_cast< sal_uInt32 >(parameters.size()))). + if (parameters.emplace( + member.type, static_cast< sal_uInt32 >(parameters.size())). second) { sal_uInt32 k = static_cast< sal_uInt32 >(parameters.size() - 1); out << indent() @@ -2546,9 +2544,7 @@ void PolyStructType::dumpComprehensiveGetCppuType(FileStream & out) << "::rtl::OUString the_pname" << k << "(the_ptype" << k << ".getTypeName());\n"; } - } else if (types.insert( - std::map< OUString, sal_uInt32 >::value_type( - member.type, static_cast< sal_uInt32 >(types.size()))). + } else if (types.emplace(member.type, static_cast< sal_uInt32 >(types.size())). second) { dumpCppuGetType(out, member.type, &name_); // For typedefs, use the resolved type name, as there will be no diff --git a/codemaker/source/cppumaker/dependencies.cxx b/codemaker/source/cppumaker/dependencies.cxx index 99da99fdf7a4..314e0213fec0 100644 --- a/codemaker/source/cppumaker/dependencies.cxx +++ b/codemaker/source/cppumaker/dependencies.cxx @@ -282,8 +282,7 @@ void Dependencies::insert(OUString const & name, Kind kind) { case UnoType::Sort::Typedef: { std::pair< Map::iterator, bool > i( - m_map.insert( - Map::value_type(n, kind))); + m_map.emplace(n, kind)); if (!i.second && kind == KIND_BASE) { assert(i.first->second != KIND_EXCEPTION); i.first->second = KIND_BASE; diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx index 7ab37166ec61..2a57b1332395 100644 --- a/codemaker/source/cppumaker/includes.cxx +++ b/codemaker/source/cppumaker/includes.cxx @@ -111,8 +111,7 @@ void Includes::add(OString const & entityName) { case codemaker::UnoType::Sort::Exception: case codemaker::UnoType::Sort::Interface: case codemaker::UnoType::Sort::Typedef: - m_map.insert( - Dependencies::Map::value_type(n, Dependencies::KIND_NORMAL)); + m_map.emplace(n, Dependencies::KIND_NORMAL); break; default: throw CannotDumpException( diff --git a/codemaker/source/javamaker/classfile.cxx b/codemaker/source/javamaker/classfile.cxx index 19de29c22d38..4431005b9e74 100644 --- a/codemaker/source/javamaker/classfile.cxx +++ b/codemaker/source/javamaker/classfile.cxx @@ -491,8 +491,7 @@ sal_uInt16 ClassFile::addIntegerInfo(sal_Int32 value) { sal_uInt16 index = nextConstantPoolIndex(1); appendU1(m_constantPool, 3); appendU4(m_constantPool, static_cast< sal_uInt32 >(value)); - if (!m_integerInfos.insert( - std::map< sal_Int32, sal_uInt16 >::value_type(value, index)).second) + if (!m_integerInfos.emplace(value, index).second) { OSL_ASSERT(false); } @@ -509,8 +508,7 @@ sal_uInt16 ClassFile::addFloatInfo(float value) { union { float floatBytes; sal_uInt32 uint32Bytes; } bytes; bytes.floatBytes = value; appendU4(m_constantPool, bytes.uint32Bytes); - if (!m_floatInfos.insert( - std::map< float, sal_uInt16 >::value_type(value, index)).second) + if (!m_floatInfos.emplace(value, index).second) { OSL_ASSERT(false); } @@ -525,8 +523,7 @@ sal_uInt16 ClassFile::addLongInfo(sal_Int64 value) { sal_uInt16 index = nextConstantPoolIndex(2); appendU1(m_constantPool, 5); appendU8(m_constantPool, static_cast< sal_uInt64 >(value)); - if (!m_longInfos.insert( - std::map< sal_Int64, sal_uInt16 >::value_type(value, index)).second) + if (!m_longInfos.emplace(value, index).second) { OSL_ASSERT(false); } @@ -543,8 +540,7 @@ sal_uInt16 ClassFile::addDoubleInfo(double value) { union { double doubleBytes; sal_uInt64 uint64Bytes; } bytes; bytes.doubleBytes = value; appendU8(m_constantPool, bytes.uint64Bytes); - if (!m_doubleInfos.insert( - std::map< double, sal_uInt16 >::value_type(value, index)).second) + if (!m_doubleInfos.emplace(value, index).second) { OSL_ASSERT(false); } @@ -685,9 +681,7 @@ sal_uInt16 ClassFile::addUtf8Info(OString const & value) { for (sal_Int32 j = 0; j < value.getLength(); ++j) { appendU1(m_constantPool, static_cast< sal_uInt8 >(value[j])); } - if (!m_utf8Infos.insert( - std::map< OString, sal_uInt16 >::value_type(value, index)). - second) + if (!m_utf8Infos.emplace(value, index).second) { OSL_ASSERT(false); } @@ -704,9 +698,7 @@ sal_uInt16 ClassFile::addClassInfo(OString const & type) { sal_uInt16 index = nextConstantPoolIndex(1); appendU1(m_constantPool, 7); appendU2(m_constantPool, nameIndex); - if (!m_classInfos.insert( - std::map< sal_uInt16, sal_uInt16 >::value_type(nameIndex, index)). - second) + if (!m_classInfos.emplace(nameIndex, index).second) { OSL_ASSERT(false); } @@ -723,9 +715,7 @@ sal_uInt16 ClassFile::addStringInfo(OString const & value) { sal_uInt16 index = nextConstantPoolIndex(1); appendU1(m_constantPool, 8); appendU2(m_constantPool, stringIndex); - if (!m_stringInfos.insert( - std::map< sal_uInt16, sal_uInt16 >::value_type(stringIndex, index)). - second) + if (!m_stringInfos.emplace(stringIndex, index).second) { OSL_ASSERT(false); } @@ -748,8 +738,7 @@ sal_uInt16 ClassFile::addFieldrefInfo( appendU1(m_constantPool, 9); appendU2(m_constantPool, classIndex); appendU2(m_constantPool, nameAndTypeIndex); - if (!m_fieldrefInfos.insert( - std::map< sal_uInt32, sal_uInt16 >::value_type(key, index)).second) + if (!m_fieldrefInfos.emplace(key, index).second) { OSL_ASSERT(false); } @@ -772,8 +761,7 @@ sal_uInt16 ClassFile::addMethodrefInfo( appendU1(m_constantPool, 10); appendU2(m_constantPool, classIndex); appendU2(m_constantPool, nameAndTypeIndex); - if (!m_methodrefInfos.insert( - std::map< sal_uInt32, sal_uInt16 >::value_type(key, index)).second) + if (!m_methodrefInfos.emplace(key, index).second) { OSL_ASSERT(false); } @@ -797,8 +785,7 @@ sal_uInt16 ClassFile::addInterfaceMethodrefInfo( appendU1(m_constantPool, 11); appendU2(m_constantPool, classIndex); appendU2(m_constantPool, nameAndTypeIndex); - if (!m_interfaceMethodrefInfos.insert( - std::map< sal_uInt32, sal_uInt16 >::value_type(key, index)).second) + if (!m_interfaceMethodrefInfos.emplace(key, index).second) { OSL_ASSERT(false); } @@ -821,8 +808,7 @@ sal_uInt16 ClassFile::addNameAndTypeInfo( appendU1(m_constantPool, 12); appendU2(m_constantPool, nameIndex); appendU2(m_constantPool, descriptorIndex); - if (!m_nameAndTypeInfos.insert( - std::map< sal_uInt32, sal_uInt16 >::value_type(key, index)).second) + if (!m_nameAndTypeInfos.emplace(key, index).second) { OSL_ASSERT(false); } diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx index 1092557e888d..f2ce8454ef26 100644 --- a/codemaker/source/javamaker/javatype.cxx +++ b/codemaker/source/javamaker/javatype.cxx @@ -742,9 +742,7 @@ void handleEnumType( { min = std::min(min, member.value); max = std::max(max, member.value); - map.insert( - std::map< sal_Int32, OString >::value_type( - member.value, codemaker::convertString(member.name))); + map.emplace(member.value, codemaker::convertString(member.name)); } sal_uInt64 size = static_cast< sal_uInt64 >(map.size()); if ((static_cast< sal_uInt64 >(max) - static_cast< sal_uInt64 >(min) @@ -1458,8 +1456,7 @@ void handlePolyStructType( for (const OUString& param : entity->getTypeParameters()) { sig.append(codemaker::convertString(param) + ":Ljava/lang/Object;"); - if (!typeParameters.insert( - std::map< OUString, sal_Int32 >::value_type(param, index++)).second) + if (!typeParameters.emplace(param, index++).second) { throw CannotDumpException("Bad type information"); //TODO } -- cgit