Use HashMap<OwnPtr> in SVGAttributeToPropertyMap

https://bugs.webkit.org/show_bug.cgi?id=75734

Reviewed by Daniel Bates.

* svg/properties/SVGAttributeToPropertyMap.cpp:
(WebCore::SVGAttributeToPropertyMap::addProperties):
(WebCore::SVGAttributeToPropertyMap::addProperty): use HashMap::add() to avoid an
extra hash lookup to set a new PropertiesVector.
(WebCore::SVGAttributeToPropertyMap::synchronizeProperties):
* svg/properties/SVGAttributeToPropertyMap.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104362 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 255ff1bf
2012-01-06 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Use HashMap<OwnPtr> in SVGAttributeToPropertyMap
https://bugs.webkit.org/show_bug.cgi?id=75734
Reviewed by Daniel Bates.
* svg/properties/SVGAttributeToPropertyMap.cpp:
(WebCore::SVGAttributeToPropertyMap::addProperties):
(WebCore::SVGAttributeToPropertyMap::addProperty): use HashMap::add() to avoid an
extra hash lookup to set a new PropertiesVector.
(WebCore::SVGAttributeToPropertyMap::synchronizeProperties):
* svg/properties/SVGAttributeToPropertyMap.h:
2012-01-06 Greg Billock <gbillock@google.com>
WebCore implementation of the Intent object
......@@ -31,7 +31,7 @@ void SVGAttributeToPropertyMap::addProperties(SVGAttributeToPropertyMap& map)
{
AttributeToPropertiesMap::iterator end = map.m_map.end();
for (AttributeToPropertiesMap::iterator it = map.m_map.begin(); it != end; ++it) {
PropertiesVector* vector = it->second;
PropertiesVector* vector = it->second.get();
ASSERT(vector);
PropertiesVector::iterator vectorEnd = vector->end();
......@@ -44,13 +44,10 @@ void SVGAttributeToPropertyMap::addProperty(const SVGPropertyInfo* info)
{
ASSERT(info);
ASSERT(info->attributeName != anyQName());
if (PropertiesVector* vector = m_map.get(info->attributeName)) {
vector->append(info);
return;
}
PropertiesVector* vector = new PropertiesVector;
OwnPtr<PropertiesVector>& vector = m_map.add(info->attributeName, nullptr).first->second;
if (!vector)
vector = adoptPtr(new PropertiesVector);
vector->append(info);
m_map.set(info->attributeName, vector);
}
void SVGAttributeToPropertyMap::animatedPropertiesForAttribute(SVGElement* ownerType, const QualifiedName& attributeName, Vector<RefPtr<SVGAnimatedProperty> >& properties)
......@@ -81,7 +78,7 @@ void SVGAttributeToPropertyMap::synchronizeProperties(SVGElement* contextElement
ASSERT(contextElement);
AttributeToPropertiesMap::iterator end = m_map.end();
for (AttributeToPropertiesMap::iterator it = m_map.begin(); it != end; ++it) {
PropertiesVector* vector = it->second;
PropertiesVector* vector = it->second.get();
ASSERT(vector);
PropertiesVector::iterator vectorEnd = vector->end();
......
......@@ -33,9 +33,6 @@ struct SVGPropertyInfo;
class SVGAttributeToPropertyMap {
public:
SVGAttributeToPropertyMap() { }
~SVGAttributeToPropertyMap() { deleteAllValues(m_map); }
bool isEmpty() const { return m_map.isEmpty(); }
void addProperties(SVGAttributeToPropertyMap&);
......@@ -52,7 +49,7 @@ private:
PassRefPtr<SVGAnimatedProperty> animatedProperty(SVGElement* contextElement, const QualifiedName& attributeName, const SVGPropertyInfo*);
typedef Vector<const SVGPropertyInfo*> PropertiesVector;
typedef HashMap<QualifiedName, PropertiesVector*> AttributeToPropertiesMap;
typedef HashMap<QualifiedName, OwnPtr<PropertiesVector> > AttributeToPropertiesMap;
AttributeToPropertiesMap m_map;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment