diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-01-24 17:49:17 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-01-24 17:52:46 +0100 |
commit | 6935acb053dcc202a7ce72cdd0fc3a30f1161be0 (patch) | |
tree | 4a9292118cd7334872f4f778ae6125ecc34034c7 /configmgr/source | |
parent | a0e4c24ecf8c92f3dba91a1b2319ec816ab57016 (diff) |
Replace "known-good" dynamic_casts with static_casts
...it avoids false warnings about unchecked dynamic_cast results from static
code analyzers, and potentially makes the code a little faster, too. (Most of
these dynamic_casts were kind of a leftover from a very early design that
dispateched on Node type via dynamic_cast instead of a Node::Kind, but which was
much too slow.)
Change-Id: I8db08a1c35783f8ea6c51eed55b11faa2d958807
Diffstat (limited to 'configmgr/source')
-rw-r--r-- | configmgr/source/access.cxx | 28 | ||||
-rw-r--r-- | configmgr/source/childaccess.cxx | 12 | ||||
-rw-r--r-- | configmgr/source/data.cxx | 2 | ||||
-rw-r--r-- | configmgr/source/valueparser.cxx | 4 | ||||
-rw-r--r-- | configmgr/source/writemodfile.cxx | 8 | ||||
-rw-r--r-- | configmgr/source/xcsparser.cxx | 6 | ||||
-rw-r--r-- | configmgr/source/xcuparser.cxx | 16 |
7 files changed, 38 insertions, 38 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index 616bd0e31cc0..1148ac526bdf 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -135,7 +135,7 @@ void Access::markChildAsModified(rtl::Reference< ChildAccess > const & child) { parent->modifiedChildren_.insert( ModifiedChildren::value_type( p->getNameInternal(), - ModifiedChild(dynamic_cast< ChildAccess * >(p.get()), false))); + ModifiedChild(static_cast< ChildAccess * >(p.get()), false))); p = parent; } } @@ -185,7 +185,7 @@ css::uno::Sequence< css::uno::Type > Access::getTypes() types.push_back( cppu::UnoType< css::container::XHierarchicalNameReplace >::get()); if (getNode()->kind() != Node::KIND_GROUP || - dynamic_cast< GroupNode * >(getNode().get())->isExtensible()) + static_cast< GroupNode * >(getNode().get())->isExtensible()) { types.push_back( cppu::UnoType< css::container::XNameContainer >::get()); @@ -322,7 +322,7 @@ css::uno::Type Access::getElementType() throw (css::uno::RuntimeException) { switch (p->kind()) { case Node::KIND_LOCALIZED_PROPERTY: return mapType( - dynamic_cast< LocalizedPropertyNode * >(p.get())->getStaticType()); + static_cast< LocalizedPropertyNode * >(p.get())->getStaticType()); case Node::KIND_GROUP: //TODO: Should a specific type be returned for a non-extensible group // with homogeneous members or for an extensible group that currently @@ -614,7 +614,7 @@ void Access::setName(OUString const & aName) { rtl::Reference< RootAccess > root(getRootAccess()); rtl::Reference< ChildAccess > childAccess( - dynamic_cast< ChildAccess * >(this)); + static_cast< ChildAccess * >(this)); localMods.add(getRelativePath()); // unbind() modifies the parent chain that // markChildAsModified() walks, so order is @@ -1179,7 +1179,7 @@ void Access::removeByName(OUString const & aName) if (getNode()->kind() == Node::KIND_GROUP) { rtl::Reference< Node > p(child->getNode()); if (p->kind() != Node::KIND_PROPERTY || - !dynamic_cast< PropertyNode * >(p.get())->isExtension()) + !static_cast< PropertyNode * >(p.get())->isExtension()) { throw css::container::NoSuchElementException( aName, static_cast< cppu::OWeakObject * >(this)); @@ -1201,7 +1201,7 @@ css::uno::Reference< css::uno::XInterface > Access::createInstance() { assert(thisIs(IS_SET|IS_UPDATE)); OUString tmplName( - dynamic_cast< SetNode * >(getNode().get())->getDefaultTemplateName()); + static_cast< SetNode * >(getNode().get())->getDefaultTemplateName()); rtl::Reference< Node > tmpl( components_.getTemplate(Data::NO_LAYER, tmplName)); if (!tmpl.is()) { @@ -1355,7 +1355,7 @@ css::uno::Any Access::queryInterface(css::uno::Type const & aType) return res; } if (getNode()->kind() != Node::KIND_GROUP || - dynamic_cast< GroupNode * >(getNode().get())->isExtensible()) + static_cast< GroupNode * >(getNode().get())->isExtensible()) { res = cppu::queryInterface( aType, static_cast< css::container::XNameContainer * >(this)); @@ -1534,7 +1534,7 @@ void Access::insertLocalizedValueChild( Modifications * localModifications) { assert(localModifications != 0); - LocalizedPropertyNode * locprop = dynamic_cast< LocalizedPropertyNode * >( + LocalizedPropertyNode * locprop = static_cast< LocalizedPropertyNode * >( getNode().get()); checkValue(value, locprop->getStaticType(), locprop->isNillable()); rtl::Reference< ChildAccess > child( @@ -2075,7 +2075,7 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) { break; case Node::KIND_SET: if (!templateName.isEmpty() && - !dynamic_cast< SetNode * >(p.get())->isValidTemplate( + !static_cast< SetNode * >(p.get())->isValidTemplate( templateName)) { return rtl::Reference< ChildAccess >(); @@ -2120,7 +2120,7 @@ css::beans::Property Access::asProperty() { switch (p->kind()) { case Node::KIND_PROPERTY: { - PropertyNode * prop = dynamic_cast< PropertyNode * >(p.get()); + PropertyNode * prop = static_cast< PropertyNode * >(p.get()); type = mapType(prop->getStaticType()); nillable = prop->isNillable(); removable = prop->isExtension(); @@ -2129,7 +2129,7 @@ css::beans::Property Access::asProperty() { case Node::KIND_LOCALIZED_PROPERTY: { LocalizedPropertyNode * locprop = - dynamic_cast< LocalizedPropertyNode *>(p.get()); + static_cast< LocalizedPropertyNode *>(p.get()); if (Components::allLocales(getRootAccess()->getLocale())) { type = cppu::UnoType< css::uno::XInterface >::get(); //TODO: correct? @@ -2144,7 +2144,7 @@ css::beans::Property Access::asProperty() { case Node::KIND_LOCALIZED_VALUE: { LocalizedPropertyNode * locprop = - dynamic_cast< LocalizedPropertyNode * >(getParentNode().get()); + static_cast< LocalizedPropertyNode * >(getParentNode().get()); type = mapType(locprop->getStaticType()); nillable = locprop->isNillable(); removable = false; //TODO ??? @@ -2223,7 +2223,7 @@ rtl::Reference< ChildAccess > Access::getFreeSetMember( static_cast< cppu::OWeakObject * >(this), 1); } assert(dynamic_cast< SetNode * >(getNode().get()) != 0); - if (!dynamic_cast< SetNode * >(getNode().get())->isValidTemplate( + if (!static_cast< SetNode * >(getNode().get())->isValidTemplate( freeAcc->getNode()->getTemplateName())) { throw css::lang::IllegalArgumentException( @@ -2252,7 +2252,7 @@ bool Access::thisIs(int what) { ((what & IS_GROUP) == 0 || k == Node::KIND_GROUP) && ((what & IS_SET) == 0 || k == Node::KIND_SET) && ((what & IS_EXTENSIBLE) == 0 || k != Node::KIND_GROUP || - dynamic_cast< GroupNode * >(p.get())->isExtensible()) && + static_cast< GroupNode * >(p.get())->isExtensible()) && ((what & IS_GROUP_MEMBER) == 0 || getParentNode()->kind() == Node::KIND_GROUP)) || ((what & IS_SET_MEMBER) == 0 || diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx index 9e80d1bb6f5b..6071df0d5b26 100644 --- a/configmgr/source/childaccess.cxx +++ b/configmgr/source/childaccess.cxx @@ -215,7 +215,7 @@ void ChildAccess::setProperty( switch (node_->kind()) { case Node::KIND_PROPERTY: { - PropertyNode * prop = dynamic_cast< PropertyNode * >(node_.get()); + PropertyNode * prop = static_cast< PropertyNode * >(node_.get()); type = prop->getStaticType(); nillable = prop->isNillable(); } @@ -238,7 +238,7 @@ void ChildAccess::setProperty( case Node::KIND_LOCALIZED_VALUE: { LocalizedPropertyNode * locprop = - dynamic_cast< LocalizedPropertyNode * >(getParentNode().get()); + static_cast< LocalizedPropertyNode * >(getParentNode().get()); type = locprop->getStaticType(); nillable = locprop->isNillable(); } @@ -258,7 +258,7 @@ css::uno::Any ChildAccess::asValue() { } switch (node_->kind()) { case Node::KIND_PROPERTY: - return dynamic_cast< PropertyNode * >(node_.get())->getValue( + return static_cast< PropertyNode * >(node_.get())->getValue( getComponents()); case Node::KIND_LOCALIZED_PROPERTY: { @@ -272,7 +272,7 @@ css::uno::Any ChildAccess::asValue() { } break; case Node::KIND_LOCALIZED_VALUE: - return dynamic_cast< LocalizedValueNode * >(node_.get())->getValue(); + return static_cast< LocalizedValueNode * >(node_.get())->getValue(); default: break; } @@ -291,11 +291,11 @@ void ChildAccess::commitChanges(bool valid, Modifications * globalModifications) globalModifications->add(path); switch (node_->kind()) { case Node::KIND_PROPERTY: - dynamic_cast< PropertyNode * >(node_.get())->setValue( + static_cast< PropertyNode * >(node_.get())->setValue( Data::NO_LAYER, *changedValue_); break; case Node::KIND_LOCALIZED_VALUE: - dynamic_cast< LocalizedValueNode * >(node_.get())->setValue( + static_cast< LocalizedValueNode * >(node_.get())->setValue( Data::NO_LAYER, *changedValue_); break; default: diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx index 8d986997fce9..f6535dff9c00 100644 --- a/configmgr/source/data.cxx +++ b/configmgr/source/data.cxx @@ -279,7 +279,7 @@ rtl::Reference< Node > Data::resolvePathRepresentation( break; case Node::KIND_SET: if (!templateName.isEmpty() && - !dynamic_cast< SetNode * >(parent.get())->isValidTemplate( + !static_cast< SetNode * >(parent.get())->isValidTemplate( templateName)) { throw css::uno::RuntimeException( diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx index 67a65a63148b..f213d645fde5 100644 --- a/configmgr/source/valueparser.cxx +++ b/configmgr/source/valueparser.cxx @@ -389,7 +389,7 @@ bool ValueParser::endElement() { } switch (node_->kind()) { case Node::KIND_PROPERTY: - dynamic_cast< PropertyNode * >(node_.get())->setValue( + static_cast< PropertyNode * >(node_.get())->setValue( layer_, value); break; case Node::KIND_LOCALIZED_PROPERTY: @@ -402,7 +402,7 @@ bool ValueParser::endElement() { localizedName_, new LocalizedValueNode(layer_, value))); } else { - dynamic_cast< LocalizedValueNode * >(i->second.get())-> + static_cast< LocalizedValueNode * >(i->second.get())-> setValue(layer_, value); } } diff --git a/configmgr/source/writemodfile.cxx b/configmgr/source/writemodfile.cxx index d42bf22a2f24..974398ceccdb 100644 --- a/configmgr/source/writemodfile.cxx +++ b/configmgr/source/writemodfile.cxx @@ -267,7 +267,7 @@ void writeNode( switch (node->kind()) { case Node::KIND_PROPERTY: { - PropertyNode * prop = dynamic_cast< PropertyNode * >(node.get()); + PropertyNode * prop = static_cast< PropertyNode * >(node.get()); writeData_(handle, RTL_CONSTASCII_STRINGPARAM("<prop oor:name=\"")); writeAttributeValue(handle, name); writeData_( @@ -314,10 +314,10 @@ void writeNode( writeAttributeValue(handle, name); writeData_(handle, RTL_CONSTASCII_STRINGPARAM("\"")); } - Type type = dynamic_cast< LocalizedPropertyNode * >(parent.get())-> + Type type = static_cast< LocalizedPropertyNode * >(parent.get())-> getStaticType(); css::uno::Any value( - dynamic_cast< LocalizedValueNode * >(node.get())->getValue()); + static_cast< LocalizedValueNode * >(node.get())->getValue()); Type dynType = getDynamicType(value); assert(dynType != TYPE_ERROR); if (type == TYPE_ANY) { @@ -392,7 +392,7 @@ void writeModifications( break; case Node::KIND_GROUP: assert( - dynamic_cast< GroupNode * >(parent.get())->isExtensible()); + static_cast< GroupNode * >(parent.get())->isExtensible()); writeData_( handle, RTL_CONSTASCII_STRINGPARAM("<prop oor:name=\"")); writeAttributeValue(handle, nodeName); diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx index ca64e2e68d68..a550240ee3d3 100644 --- a/configmgr/source/xcsparser.cxx +++ b/configmgr/source/xcsparser.cxx @@ -74,7 +74,7 @@ void merge( NodeMap::iterator i1(members.find(i2->first)); if (i1 == members.end()) { if (i2->second->kind() == Node::KIND_PROPERTY && - dynamic_cast< GroupNode * >( + static_cast< GroupNode * >( original.get())->isExtensible()) { members.insert(*i2); @@ -91,7 +91,7 @@ void merge( NodeMap & members = original->getMembers(); NodeMap::iterator i1(members.find(i2->first)); if (i1 == members.end()) { - if (dynamic_cast< SetNode * >(original.get())-> + if (static_cast< SetNode * >(original.get())-> isValidTemplate(i2->second->getTemplateName())) { members.insert(*i2); @@ -235,7 +235,7 @@ bool XcsParser::startElement( { handleSetItem( reader, - dynamic_cast< SetNode * >(elements_.top().node.get())); + static_cast< SetNode * >(elements_.top().node.get())); return true; } break; diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx index f6f7f305b83f..9499f9764425 100644 --- a/configmgr/source/xcuparser.cxx +++ b/configmgr/source/xcuparser.cxx @@ -112,7 +112,7 @@ bool XcuParser::startElement( { handlePropValue( reader, - dynamic_cast< PropertyNode * >(state_.top().node.get())); + static_cast< PropertyNode * >(state_.top().node.get())); } else { throw css::uno::RuntimeException( ("bad property node member <" + name.convertFromUtf8() + @@ -126,7 +126,7 @@ bool XcuParser::startElement( { handleLocpropValue( reader, - dynamic_cast< LocalizedPropertyNode * >( + static_cast< LocalizedPropertyNode * >( state_.top().node.get())); } else { throw css::uno::RuntimeException( @@ -146,7 +146,7 @@ bool XcuParser::startElement( { handleGroupProp( reader, - dynamic_cast< GroupNode * >(state_.top().node.get())); + static_cast< GroupNode * >(state_.top().node.get())); } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && name.equals("node")) { @@ -163,7 +163,7 @@ bool XcuParser::startElement( name.equals("node")) { handleSetNode( - reader, dynamic_cast< SetNode * >(state_.top().node.get())); + reader, static_cast< SetNode * >(state_.top().node.get())); } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && name.equals("prop")) { @@ -383,7 +383,7 @@ void XcuParser::handleItem(xmlreader::XmlReader & reader) { state_.push(State::Ignore(true)); return; case Node::KIND_LOCALIZED_PROPERTY: - valueParser_.type_ = dynamic_cast< LocalizedPropertyNode * >( + valueParser_.type_ = static_cast< LocalizedPropertyNode * >( node.get())->getStaticType(); break; default: @@ -542,7 +542,7 @@ void XcuParser::handleLocpropValue( members[name] = new LocalizedValueNode( valueParser_.getLayer(), css::uno::Any()); } else { - dynamic_cast< LocalizedValueNode * >( + static_cast< LocalizedValueNode * >( i->second.get())->setValue( valueParser_.getLayer(), css::uno::Any()); } @@ -635,7 +635,7 @@ void XcuParser::handleGroupProp( case Node::KIND_LOCALIZED_PROPERTY: handleLocalizedGroupProp( reader, - dynamic_cast< LocalizedPropertyNode * >(i->second.get()), name, + static_cast< LocalizedPropertyNode * >(i->second.get()), name, type, op, finalized); break; default: @@ -688,7 +688,7 @@ void XcuParser::handlePlainGroupProp( NodeMap::iterator const & propertyIndex, OUString const & name, Type type, Operation operation, bool finalized) { - PropertyNode * property = dynamic_cast< PropertyNode * >( + PropertyNode * property = static_cast< PropertyNode * >( propertyIndex->second.get()); if (property->getLayer() > valueParser_.getLayer()) { state_.push(State::Ignore(true)); |